Skip to content

Commit

Permalink
TabBarIOS tintColor
Browse files Browse the repository at this point in the history
Summary:
[Origin Pull request](facebook#961) from [cmcewen](https://github.com/cmcewen)

All the work have been done by @cmcewen, I just rebased his work with the master.
Closes facebook#1337
Github Author: Stan Chollet <stanislas.chollet@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
  • Loading branch information
tsunammis authored and tadeuzagallo committed May 28, 2015
1 parent 947ee2a commit b0fb6e0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Examples/UIExplorer/TabBarIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ var TabBarExample = React.createClass({

render: function() {
return (
<TabBarIOS>
<TabBarIOS
tintColor="black"
barTintColor="#3abeff'">
<TabBarIOS.Item
title="Blue Tab"
selected={this.state.selectedTab === 'blueTab'}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion Libraries/Components/TabBarIOS/TabBarIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,22 @@ var TabBarIOS = React.createClass({

propTypes: {
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() {
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}
</RCTTabBar>
);
Expand Down
3 changes: 3 additions & 0 deletions React/Views/RCTTabBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

@interface RCTTabBar : UIView

@property (nonatomic, strong) UIColor *tintColor;
@property (nonatomic, strong) UIColor *barTintColor;

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;

@end
10 changes: 10 additions & 0 deletions React/Views/RCTTabBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ - (void)reactBridgeDidFinishTransaction
}];
}

- (void)setBarTintColor:(UIColor *)barTintColor
{
_tabController.tabBar.barTintColor = barTintColor;
}

- (void)setTintColor:(UIColor *)tintColor
{
_tabController.tabBar.tintColor = tintColor;
}

#pragma mark - UITabBarControllerDelegate

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
Expand Down
3 changes: 3 additions & 0 deletions React/Views/RCTTabBarManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ - (UIView *)view
return [[RCTTabBar alloc] initWithEventDispatcher:_bridge.eventDispatcher];
}

RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(barTintColor, UIColor)

@end

0 comments on commit b0fb6e0

Please sign in to comment.