Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,20 @@ export default class App extends React.Component<{}, $FlowFixMeState> {
<Text style={styles.text}>
Segmented controls can have defined fontSize
</Text>
<View style={styles.segmentContainer}>
<SegmentedControl
values={['One', 'Two']}
style={{height: 80}}
fontSize={32}
/>
</View>
<SegmentedControl
values={['One', 'Two']}
style={{height: 80}}
fontSize={32}
textColor="blue"
tintColor="green"
activeTextColor="red"
/>
</View>
<View>
Expand Down
14 changes: 10 additions & 4 deletions ios/RNCSegmentedControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down