@@ -25,11 +25,33 @@ - (UIView *)view
2525RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
2626RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
2727RCT_EXPORT_VIEW_PROPERTY(textColor, UIColor)
28- RCT_EXPORT_VIEW_PROPERTY(fontSize, NSInteger )
2928RCT_EXPORT_VIEW_PROPERTY(activeTextColor, UIColor)
3029RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL )
3130RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL )
3231RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
3332RCT_EXPORT_VIEW_PROPERTY(appearance, NSString )
3433
34+ RCT_CUSTOM_VIEW_PROPERTY(fontStyle, NSObject , RNCSegmentedControl)
35+ {
36+ if (json) {
37+ NSInteger fontSize = json[@" fontSize" ] ? [RCTConvert NSInteger: json[@" fontSize" ]] : 13.0 ;
38+
39+ UIFont *idleFont = [UIFont systemFontOfSize: fontSize];
40+ UIFont *selectedFont = [UIFont boldSystemFontOfSize: fontSize];
41+
42+ if (json[@" fontFamilyIdle" ] && json[@" fontFamilySelected" ]) {
43+ idleFont = [UIFont fontWithName: json[@" fontFamilyIdle" ] size: fontSize];
44+ selectedFont = [UIFont fontWithName: json[@" fontFamilySelected" ] size: fontSize];
45+ } else if (json[@" fontFamilyIdle" ]) {
46+ idleFont = [UIFont fontWithName: json[@" fontFamilyIdle" ] size: fontSize];
47+ } else if (json[@" fontFamilySelected" ]) {
48+ selectedFont = [UIFont fontWithName: json[@" fontFamilySelected" ] size: fontSize];
49+ }
50+
51+ [view setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: idleFont, NSFontAttributeName , nil ] forState: UIControlStateNormal];
52+
53+ [view setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: selectedFont, NSFontAttributeName , nil ] forState: UIControlStateSelected];
54+ }
55+ }
56+
3557@end
0 commit comments