mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Enable setting color of unselected tabs
This commit is contained in:
@@ -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}>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user