Enable setting color of unselected tabs

This commit is contained in:
Urban Cvek
2016-04-27 21:17:07 +02:00
parent 171c7230b1
commit c206417cb4
4 changed files with 10 additions and 0 deletions
@@ -27,6 +27,10 @@ var TabBarIOS = React.createClass({
propTypes: {
...View.propTypes,
style: View.propTypes.style,
/**
* Color of text on unselected tabs
*/
unselectedTintColor: ColorPropType,
/**
* Color of the currently selected tab icon
*/
@@ -45,6 +49,7 @@ var TabBarIOS = React.createClass({
return (
<RCTTabBar
style={[styles.tabGroup, this.props.style]}
unselectedTintColor={this.props.unselectedTintColor}
tintColor={this.props.tintColor}
barTintColor={this.props.barTintColor}
translucent={this.props.translucent !== false}>
+1
View File
@@ -11,6 +11,7 @@
@interface RCTTabBar : UIView
@property (nonatomic, strong) UIColor *unselectedTintColor;
@property (nonatomic, strong) UIColor *tintColor;
@property (nonatomic, strong) UIColor *barTintColor;
@property (nonatomic, assign) BOOL translucent;
+3
View File
@@ -105,6 +105,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
_tabController.viewControllers = viewControllers;
_tabsChanged = NO;
}
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:_unselectedTintColor, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.tintColor, NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
[_tabViews enumerateObjectsUsingBlock:
^(RCTTabBarItem *tab, NSUInteger index, __unused BOOL *stop) {
+1
View File
@@ -21,6 +21,7 @@ RCT_EXPORT_MODULE()
return [RCTTabBar new];
}
RCT_EXPORT_VIEW_PROPERTY(unselectedTintColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(barTintColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(translucent, BOOL)