Skip to content
Permalink
Browse files
Fix tintColor in SegmentedControlIOS component
Summary:
iOS 13 introduced a new design for `UISegmentedControl` and new APIs to control this. `[UISegmentedControl tintColor]` is now ignored.

We try to maintain backwards compatibility so the appearance is as close as possible to iOS 12.

Changelog:
Fix `tintColor` on SegmentedControlIOS

Reviewed By: shergin

Differential Revision: D17905892

fbshipit-source-id: 964ac64c8543660929c43b427dce4f78094b1255
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 15, 2019
1 parent 8bce9c5 commit be89e4d928a504de304f5afb19bd3cc15ae3eb7d
Showing 1 changed file with 15 additions and 0 deletions.
@@ -39,6 +39,21 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex
super.selectedSegmentIndex = selectedIndex;
}

- (void)setTintColor:(UIColor *)tintColor
{
[super setTintColor:tintColor];
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
if (@available(iOS 13.0, *)) {
[self setSelectedSegmentTintColor:tintColor];
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}
forState:UIControlStateSelected];
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: tintColor}
forState:UIControlStateNormal];
}
#endif
}

- (void)didChange
{
_selectedIndex = self.selectedSegmentIndex;

0 comments on commit be89e4d

Please sign in to comment.