mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 12:15:37 +08:00
TabBarIOS tintColor
Summary: [Origin Pull request](https://github.com/facebook/react-native/pull/961) from [cmcewen](https://github.com/cmcewen) All the work have been done by @cmcewen, I just rebased his work with the master. Closes https://github.com/facebook/react-native/pull/1337 Github Author: Stan Chollet <stanislas.chollet@gmail.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
@@ -48,7 +48,9 @@ var TabBarExample = React.createClass({
|
|||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<TabBarIOS>
|
<TabBarIOS
|
||||||
|
tintColor="black"
|
||||||
|
barTintColor="#3abeff'">
|
||||||
<TabBarIOS.Item
|
<TabBarIOS.Item
|
||||||
title="Blue Tab"
|
title="Blue Tab"
|
||||||
selected={this.state.selectedTab === 'blueTab'}
|
selected={this.state.selectedTab === 'blueTab'}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
@@ -25,11 +25,22 @@ var TabBarIOS = React.createClass({
|
|||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
style: View.propTypes.style,
|
style: View.propTypes.style,
|
||||||
|
/**
|
||||||
|
* Color of the currently selected tab icon
|
||||||
|
*/
|
||||||
|
tintColor: React.PropTypes.string,
|
||||||
|
/**
|
||||||
|
* Background color of the tab bar
|
||||||
|
*/
|
||||||
|
barTintColor: React.PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<RCTTabBar style={[styles.tabGroup, this.props.style]}>
|
<RCTTabBar
|
||||||
|
style={[styles.tabGroup, this.props.style]}
|
||||||
|
tintColor={this.props.tintColor}
|
||||||
|
barTintColor={this.props.barTintColor}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</RCTTabBar>
|
</RCTTabBar>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
@interface RCTTabBar : UIView
|
@interface RCTTabBar : UIView
|
||||||
|
|
||||||
|
@property (nonatomic, strong) UIColor *tintColor;
|
||||||
|
@property (nonatomic, strong) UIColor *barTintColor;
|
||||||
|
|
||||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -114,6 +114,16 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setBarTintColor:(UIColor *)barTintColor
|
||||||
|
{
|
||||||
|
_tabController.tabBar.barTintColor = barTintColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setTintColor:(UIColor *)tintColor
|
||||||
|
{
|
||||||
|
_tabController.tabBar.tintColor = tintColor;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - UITabBarControllerDelegate
|
#pragma mark - UITabBarControllerDelegate
|
||||||
|
|
||||||
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
|
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
|
||||||
|
|||||||
@@ -23,4 +23,7 @@ RCT_EXPORT_MODULE()
|
|||||||
return [[RCTTabBar alloc] initWithEventDispatcher:_bridge.eventDispatcher];
|
return [[RCTTabBar alloc] initWithEventDispatcher:_bridge.eventDispatcher];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(barTintColor, UIColor)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user