diff --git a/Examples/UIExplorer/js/TabBarIOSExample.js b/Examples/UIExplorer/js/TabBarIOSExample.js index 1e659b54c..242124daa 100644 --- a/Examples/UIExplorer/js/TabBarIOSExample.js +++ b/Examples/UIExplorer/js/TabBarIOSExample.js @@ -73,6 +73,7 @@ class TabBarExample extends React.Component { 0 ? this.state.notifCount : undefined} + badgeColor="black" selected={this.state.selectedTab === 'redTab'} onPress={() => { this.setState({ diff --git a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index 80aa46b78..4adc08744 100644 --- a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js @@ -16,6 +16,7 @@ var React = require('React'); var StaticContainer = require('StaticContainer.react'); var StyleSheet = require('StyleSheet'); var View = require('View'); +var ColorPropType = require('ColorPropType'); var requireNativeComponent = require('requireNativeComponent'); @@ -29,6 +30,10 @@ class TabBarItemIOS extends React.Component { React.PropTypes.string, React.PropTypes.number, ]), + /** + * Background color for the badge. Available since iOS 10. + */ + badgeColor: ColorPropType, /** * Items comes with a few predefined system icons. Note that if you are * using them, the title and selectedIcon will be overridden with the diff --git a/React/Views/RCTTabBarItem.m b/React/Views/RCTTabBarItem.m index 0b4a0ca37..0a8ab5d32 100644 --- a/React/Views/RCTTabBarItem.m +++ b/React/Views/RCTTabBarItem.m @@ -105,6 +105,13 @@ RCT_ENUM_CONVERTER(UITabBarSystemItem, (@{ } } +- (void)setBadgeColor:(UIColor *)bagdeColor +{ +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 + _barItem.badgeColor = bagdeColor; +#endif +} + - (UIViewController *)reactViewController { return self.superview.reactViewController; diff --git a/React/Views/RCTTabBarItemManager.m b/React/Views/RCTTabBarItemManager.m index 9bfa13deb..6ea7f632a 100644 --- a/React/Views/RCTTabBarItemManager.m +++ b/React/Views/RCTTabBarItemManager.m @@ -28,6 +28,7 @@ RCT_EXPORT_VIEW_PROPERTY(icon, UIImage) RCT_EXPORT_VIEW_PROPERTY(selectedIcon, UIImage) RCT_EXPORT_VIEW_PROPERTY(systemIcon, UITabBarSystemItem) RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) +RCT_EXPORT_VIEW_PROPERTY(badgeColor, UIColor) RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem) { view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;