Skip to content

Commit 0923641

Browse files
committed
fix(tabs): ios wrong color set in TabStrip items
1 parent 6a7fa01 commit 0923641

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/core-tabs/tab-navigation/index.ios.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -830,34 +830,24 @@ export abstract class TabNavigation<
830830

831831
private setItemColors(): void {
832832
if (this.mSelectedItemColor) {
833+
this.viewController.tabBar.setImageTintColorForState(this.mSelectedItemColor.ios, UIControlState.Selected);
833834
this.viewController.tabBar.setTitleColorForState(this.mSelectedItemColor.ios, UIControlState.Selected);
834835
}
835836
if (this.mUnSelectedItemColor) {
837+
this.viewController.tabBar.setImageTintColorForState(this.mUnSelectedItemColor.ios, UIControlState.Normal);
836838
this.viewController.tabBar.setTitleColorForState(this.mUnSelectedItemColor.ios, UIControlState.Normal);
837839
}
838840
}
839841

840842
private setIconColor(tabStripItem: TabStripItem, forceReload = false): void {
841843
const nativeView = tabStripItem.nativeView;
842-
if (!nativeView) {
843-
return;
844-
}
845-
// if there is no change in the css color and there is no item color set
846-
// we don't need to reload the icon
847-
if (!forceReload && !this.mSelectedItemColor && !this.mUnSelectedItemColor) {
848-
return;
849-
}
850-
851-
// if selectedItemColor or unSelectedItemColor is set we don't respect the color from the style
844+
if (nativeView && (forceReload || (!this.mUnSelectedItemColor && !this.mSelectedItemColor))) {
845+
// if selectedItemColor or unSelectedItemColor is set we don't respect the color from the style
846+
const tabStripColor = this.selectedIndex === tabStripItem.index ? this.mSelectedItemColor : this.mUnSelectedItemColor;
847+
const image = this.getIcon(tabStripItem, tabStripColor);
852848

853-
if (this.mSelectedItemColor) {
854-
const image = this.getIcon(tabStripItem, this.mSelectedItemColor);
855-
nativeView.selectedImage = image;
856-
}
857-
858-
if (this.mUnSelectedItemColor) {
859-
const image = this.getIcon(tabStripItem, this.mUnSelectedItemColor);
860849
nativeView.image = image;
850+
nativeView.selectedImage = image;
861851
}
862852
}
863853

0 commit comments

Comments
 (0)