diff --git a/example/App.js b/example/App.js index 4f61563f..da293937 100644 --- a/example/App.js +++ b/example/App.js @@ -78,10 +78,20 @@ export default class App extends React.Component<{}, $FlowFixMeState> { Segmented controls can have defined fontSize + + + diff --git a/ios/RNCSegmentedControl.m b/ios/RNCSegmentedControl.m index 1f5a7307..72eba44c 100644 --- a/ios/RNCSegmentedControl.m +++ b/ios/RNCSegmentedControl.m @@ -41,10 +41,14 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex - (void)setFontSize:(NSInteger)fontSize { - UIFont *font = [UIFont boldSystemFontOfSize: fontSize]; + UIFont *font = [UIFont systemFontOfSize: fontSize]; [_attributes setObject: font forKey:NSFontAttributeName]; [self setTitleTextAttributes:_attributes forState:UIControlStateNormal]; + UIFont *fontBold = [UIFont boldSystemFontOfSize: fontSize]; + [_attributes setObject: fontBold forKey:NSFontAttributeName]; + [self setTitleTextAttributes:_attributes + forState:UIControlStateSelected]; } - (void)setBackgroundColor:(UIColor *)backgroundColor @@ -74,7 +78,8 @@ - (void)setActiveTextColor:(UIColor *)textColor #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 setTitleTextAttributes:@{NSForegroundColorAttributeName: textColor} + [_attributes setObject: textColor forKey:NSForegroundColorAttributeName]; + [self setTitleTextAttributes:_attributes forState:UIControlStateSelected]; } #endif @@ -87,8 +92,9 @@ - (void)setTintColor:(UIColor *)tintColor __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 if (@available(iOS 13.0, *)) { [self setSelectedSegmentTintColor:tintColor]; - [self setTitleTextAttributes:@{NSForegroundColorAttributeName: tintColor} - forState:UIControlStateNormal]; + [_attributes setObject: tintColor forKey:NSForegroundColorAttributeName]; + [self setTitleTextAttributes:_attributes + forState:UIControlStateNormal]; } #endif } diff --git a/package.json b/package.json index d3c0ded7..27a50694 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@react-native-community/segmented-control", - "version": "1.6.0", + "version": "1.6.1", "description": "React Native SegmentedControlIOS library", "main": "js/index.js", "types": "index.d.ts",