From a91752a2739d128db1bc0c358db959aeb7fb1d9c Mon Sep 17 00:00:00 2001 From: evanbacon Date: Wed, 13 Nov 2024 13:57:56 -0600 Subject: [PATCH 1/3] support transparent large header --- ios/RNSScreenStackHeaderConfig.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index d0b9e4be74..cb8e47c393 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -670,6 +670,17 @@ + (void)updateViewController:(UIViewController *)vc UINavigationBarAppearance *scrollEdgeAppearance = [[UINavigationBarAppearance alloc] initWithBarAppearance:appearance]; + if (config.largeTitleBackgroundColor != nil) { + // Add support for using a fully transparent bar when the backgroundColor is set to transparent. + if (CGColorGetAlpha(config.largeTitleBackgroundColor.CGColor) == 0.) { + // This will also remove the background blur effect in the large title which is otherwise inherited from the standard appearance. + [scrollEdgeAppearance configureWithTransparentBackground]; + // This must be set to nil otherwise a default view will be added to the navigation bar background with an opaque background. + scrollEdgeAppearance.backgroundColor = nil; + } else { + scrollEdgeAppearance.backgroundColor = config.largeTitleBackgroundColor; + } + } if (config.largeTitleBackgroundColor != nil) { scrollEdgeAppearance.backgroundColor = config.largeTitleBackgroundColor; } From 55581af13e9d8d5461908afda88a39aa351b0aa8 Mon Sep 17 00:00:00 2001 From: evanbacon Date: Wed, 13 Nov 2024 14:10:40 -0600 Subject: [PATCH 2/3] preserve shadow props --- ios/RNSScreenStackHeaderConfig.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index cb8e47c393..67df042cf4 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -442,8 +442,16 @@ + (UINavigationBarAppearance *)buildAppearance:(UIViewController *)vc UINavigationBarAppearance *appearance = [UINavigationBarAppearance new]; if (config.backgroundColor && CGColorGetAlpha(config.backgroundColor.CGColor) == 0.) { + // Preserve the shadow properties in case the user wants to show the shadow on scroll. + UIColor *shadowColor = appearance.shadowColor; + UIImage *shadowImage = appearance.shadowImage; // transparent background color [appearance configureWithTransparentBackground]; + + if (!config.hideShadow) { + appearance.shadowColor = shadowColor; + appearance.shadowImage = shadowImage; + } } else { [appearance configureWithOpaqueBackground]; } From 0b8c9d4e758757df887868d06fd23bc26497fec1 Mon Sep 17 00:00:00 2001 From: Evan Bacon Date: Thu, 14 Nov 2024 08:06:25 -0600 Subject: [PATCH 3/3] Update ios/RNSScreenStackHeaderConfig.mm --- ios/RNSScreenStackHeaderConfig.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 67df042cf4..c575478d59 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -689,9 +689,6 @@ + (void)updateViewController:(UIViewController *)vc scrollEdgeAppearance.backgroundColor = config.largeTitleBackgroundColor; } } - if (config.largeTitleBackgroundColor != nil) { - scrollEdgeAppearance.backgroundColor = config.largeTitleBackgroundColor; - } if (config.largeTitleHideShadow) { scrollEdgeAppearance.shadowColor = nil; }