Skip to content

Commit d0d5b3e

Browse files
authored
fix: allow combining attributes (#83)
1 parent 3287d67 commit d0d5b3e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

example/App.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,20 @@ export default class App extends React.Component<{}, $FlowFixMeState> {
7878
<Text style={styles.text}>
7979
Segmented controls can have defined fontSize
8080
</Text>
81+
<View style={styles.segmentContainer}>
82+
<SegmentedControl
83+
values={['One', 'Two']}
84+
style={{height: 80}}
85+
fontSize={32}
86+
/>
87+
</View>
8188
<SegmentedControl
8289
values={['One', 'Two']}
8390
style={{height: 80}}
8491
fontSize={32}
92+
textColor="blue"
93+
tintColor="green"
94+
activeTextColor="red"
8595
/>
8696
</View>
8797
<View>

ios/RNCSegmentedControl.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ - (void)setActiveTextColor:(UIColor *)textColor
7878
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
7979
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
8080
if (@available(iOS 13.0, *)) {
81-
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: textColor}
81+
[_attributes setObject: textColor forKey:NSForegroundColorAttributeName];
82+
[self setTitleTextAttributes:_attributes
8283
forState:UIControlStateSelected];
8384
}
8485
#endif
@@ -91,8 +92,9 @@ - (void)setTintColor:(UIColor *)tintColor
9192
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
9293
if (@available(iOS 13.0, *)) {
9394
[self setSelectedSegmentTintColor:tintColor];
94-
[self setTitleTextAttributes:@{NSForegroundColorAttributeName: tintColor}
95-
forState:UIControlStateNormal];
95+
[_attributes setObject: tintColor forKey:NSForegroundColorAttributeName];
96+
[self setTitleTextAttributes:_attributes
97+
forState:UIControlStateNormal];
9698
}
9799
#endif
98100
}

0 commit comments

Comments
 (0)