Skip to content

Commit

Permalink
fix(ios): tab group "titleColor" handling on iOS 15
Browse files Browse the repository at this point in the history
Fixes TIMOB-28550
  • Loading branch information
jquick-axway authored and ewanharris committed Nov 17, 2021
1 parent 58037db commit 6fae767
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions iphone/Classes/TiUITabProxy.m
Expand Up @@ -592,16 +592,12 @@ - (void)updateTabBarItem
}

if (image != nil) {
if ([image respondsToSelector:@selector(imageWithRenderingMode:)]) {
NSInteger theMode = iconOriginal ? UIImageRenderingModeAlwaysOriginal : UIImageRenderingModeAlwaysTemplate;
image = [image imageWithRenderingMode:theMode];
}
NSInteger theMode = iconOriginal ? UIImageRenderingModeAlwaysOriginal : UIImageRenderingModeAlwaysTemplate;
image = [image imageWithRenderingMode:theMode];
}
if (activeImage != nil) {
if ([activeImage respondsToSelector:@selector(imageWithRenderingMode:)]) {
NSInteger theMode = activeIconOriginal ? UIImageRenderingModeAlwaysOriginal : UIImageRenderingModeAlwaysTemplate;
activeImage = [activeImage imageWithRenderingMode:theMode];
}
NSInteger theMode = activeIconOriginal ? UIImageRenderingModeAlwaysOriginal : UIImageRenderingModeAlwaysTemplate;
activeImage = [activeImage imageWithRenderingMode:theMode];
}

TiColor *tintColor = [TiUtils colorValue:[self valueForKey:@"tintColor"]];
Expand Down Expand Up @@ -646,15 +642,35 @@ - (void)updateTabBarItem
if (titleColor == nil) {
titleColor = [TiUtils colorValue:[tabGroup valueForKey:@"titleColor"]];
}
if (titleColor != nil) {
[ourItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[titleColor color], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
}
TiColor *activeTitleColor = [TiUtils colorValue:[self valueForKey:@"activeTitleColor"]];
if (activeTitleColor == nil) {
activeTitleColor = [TiUtils colorValue:[tabGroup valueForKey:@"activeTitleColor"]];
}
if (activeTitleColor != nil) {
[ourItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[activeTitleColor color], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
if ((titleColor != nil) || (activeTitleColor != nil)) {
#if IS_SDK_IOS_15
if ([TiUtils isIOSVersionOrGreater:@"15.0"]) {
UITabBarAppearance *appearance = UITabBarAppearance.new;
if (titleColor != nil) {
UITabBarItemStateAppearance *normalAppearance = appearance.stackedLayoutAppearance.normal;
normalAppearance.titleTextAttributes = @{ NSForegroundColorAttributeName : [titleColor color] };
}
if (activeTitleColor != nil) {
UITabBarItemStateAppearance *selectedAppearance = appearance.stackedLayoutAppearance.selected;
selectedAppearance.titleTextAttributes = @{ NSForegroundColorAttributeName : [activeTitleColor color] };
}
ourItem.standardAppearance = appearance;
ourItem.scrollEdgeAppearance = appearance;
} else {
#endif
if (titleColor != nil) {
[ourItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[titleColor color], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
}
if (activeTitleColor != nil) {
[ourItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[activeTitleColor color], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
}
#if IS_SDK_IOS_15
}
#endif
}

if (iconInsets != nil) {
Expand Down

0 comments on commit 6fae767

Please sign in to comment.