Skip to content

Commit

Permalink
fix(ios): tab background color on iOS 15 when setting title color
Browse files Browse the repository at this point in the history
Fixes TIMOB-28551
  • Loading branch information
jquick-axway authored and ewanharris committed Nov 17, 2021
1 parent 3a5153c commit 248763a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions iphone/Classes/TiUITabGroup.m
Expand Up @@ -375,8 +375,17 @@ - (void)setTabsBackgroundColor_:(id)value
[tabBar setBarTintColor:[color color]];
#if IS_SDK_IOS_15
if ([TiUtils isIOSVersionOrGreater:@"15.0"]) {
// Update main tab bar's appearance.
tabBar.standardAppearance.backgroundColor = [color color];
tabBar.scrollEdgeAppearance.backgroundColor = [color color];

// We must also update each tab in case they override main tab bar's appearance.
id tabs = [[self proxy] valueForKey:@"tabs"];
if ([tabs isKindOfClass:[NSArray class]]) {
for (TiUITabProxy *tabProxy in (NSArray *)tabs) {
[tabProxy updateTabBarItem];
}
}
}
#endif
}
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUITabProxy.h
Expand Up @@ -51,6 +51,7 @@
- (void)handleDidFocus:(NSDictionary *)event;
- (void)handleWillShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (void)handleDidShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (void)updateTabBarItem;

@end

Expand Down
4 changes: 4 additions & 0 deletions iphone/Classes/TiUITabProxy.m
Expand Up @@ -658,6 +658,10 @@ - (void)updateTabBarItem
UITabBarItemStateAppearance *selectedAppearance = appearance.stackedLayoutAppearance.selected;
selectedAppearance.titleTextAttributes = @{ NSForegroundColorAttributeName : [activeTitleColor color] };
}
TiColor *backgroundColor = [TiUtils colorValue:[tabGroup valueForKey:@"tabsBackgroundColor"]];
if (backgroundColor != nil) {
appearance.backgroundColor = [backgroundColor color];
}
ourItem.standardAppearance = appearance;
ourItem.scrollEdgeAppearance = appearance;
} else {
Expand Down

0 comments on commit 248763a

Please sign in to comment.