Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): fix issues for navigation bar in iOS 13 #11209

Merged
merged 3 commits into from
Sep 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 41 additions & 11 deletions iphone/TitaniumKit/TitaniumKit/Sources/Modules/TiUIWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,26 @@ - (void)preferredContentSizeDidChangeForChildContentContainer:(id<UIContentConta
- (void)viewWillAppear:(BOOL)animated; // Called when the view is about to made visible. Default does nothing
{
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
// TO DO: Refactor navigation bar customisation iOS 13
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
TiColor *newColor = [TiUtils colorValue:[self valueForKey:@"barColor"]];
if (newColor == nil) {
newColor = [TiUtils colorValue:[[self tabGroup] valueForKey:@"barColor"]];
}
if (controller != nil && !(controller.edgesForExtendedLayout == UIRectEdgeTop || controller.edgesForExtendedLayout == UIRectEdgeAll)) {
UINavigationBarAppearance *appearance = controller.navigationController.navigationBar.standardAppearance;
[appearance configureWithTransparentBackground];
if (newColor == nil) {
//Get from TabGroup
newColor = [TiUtils colorValue:[[self tabGroup] valueForKey:@"barColor"]];
}
if (newColor == nil) {
appearance.backgroundColor = self.view.backgroundColor;
if ([TiUtils boolValue:[self valueForKey:@"largeTitleEnabled"] def:NO]) {
[appearance configureWithTransparentBackground];
if (newColor == nil) {
appearance.backgroundColor = self.view.backgroundColor;
} else {
appearance.backgroundColor = newColor.color;
}
} else {
appearance.backgroundColor = newColor.color;
[appearance configureWithDefaultBackground];
if (newColor != nil) {
appearance.backgroundColor = newColor.color;
}
}
controller.navigationController.navigationBar.standardAppearance = appearance;
controller.navigationController.navigationBar.scrollEdgeAppearance = appearance;
Expand Down Expand Up @@ -394,10 +401,23 @@ - (void)setTitleAttributes:(id)args
}

if (shouldUpdateNavBar && ([controller navigationController] != nil)) {
UINavigationBar *navigationBar = controller.navigationController.navigationBar;
if ([TiUtils isIOSVersionOrGreater:@"11.0"] && [TiUtils boolValue:[self valueForKey:@"largeTitleEnabled"] def:NO]) {
[[[controller navigationController] navigationBar] setLargeTitleTextAttributes:theAttributes];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
navigationBar.standardAppearance.largeTitleTextAttributes = theAttributes;
navigationBar.scrollEdgeAppearance.largeTitleTextAttributes = theAttributes;
}
#endif
navigationBar.largeTitleTextAttributes = theAttributes;
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
navigationBar.standardAppearance.titleTextAttributes = theAttributes;
navigationBar.scrollEdgeAppearance.titleTextAttributes = theAttributes;
}
[[[controller navigationController] navigationBar] setTitleTextAttributes:theAttributes];
#endif
navigationBar.titleTextAttributes = theAttributes;
}
}

Expand All @@ -417,7 +437,17 @@ - (void)updateBarImage
[ourNB setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
} else {
UIImage *resizableImage = [theImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
[ourNB setBackgroundImage:resizableImage forBarMetrics:UIBarMetricsDefault];

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if ([TiUtils isIOSVersionOrGreater:@"13.0"]) {
ourNB.standardAppearance.backgroundImage = resizableImage;
ourNB.scrollEdgeAppearance.backgroundImage = resizableImage;
}
#endif

[ourNB setBackgroundImage:resizableImage
forBarMetrics:UIBarMetricsDefault];

//You can only set up the shadow image with a custom background image.
id shadowImageValue = [self valueForUndefinedKey:@"shadowImage"];
theImage = [TiUtils toImage:shadowImageValue proxy:self];
Expand Down