Skip to content

Commit

Permalink
fix(ios): non large title navigation bars show default navigation bar (
Browse files Browse the repository at this point in the history
…#11199)

* fix(ios): non large title navigation bars show default navigation bar

* fix(ios): tittle attributes issue fixed for nav bar for ios 13

* fix(ios): background image setting for navigation bar
  • Loading branch information
vijaysingh-axway authored and lokeshchdhry committed Sep 10, 2019
1 parent 27c9636 commit 11aef9c
Showing 1 changed file with 41 additions and 11 deletions.
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

0 comments on commit 11aef9c

Please sign in to comment.