diff --git a/Examples/UIExplorer/RefreshControlExample.js b/Examples/UIExplorer/RefreshControlExample.js index b6bca301316..e3fb6e184d8 100644 --- a/Examples/UIExplorer/RefreshControlExample.js +++ b/Examples/UIExplorer/RefreshControlExample.js @@ -94,6 +94,7 @@ const RefreshControlExample = React.createClass({ onRefresh={this._onRefresh} tintColor="#ff0000" title="Loading..." + titleColor="#00ff00" colors={['#ff0000', '#00ff00', '#0000ff']} progressBackgroundColor="#ffff00" /> diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index f79305d935a..1a9389f4a4e 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -92,6 +92,11 @@ const RefreshControl = React.createClass({ * @platform ios */ tintColor: ColorPropType, + /** + * Title color. + * @platform ios + */ + titleColor: ColorPropType, /** * The title displayed under the refresh indicator. * @platform ios diff --git a/React/Views/RCTRefreshControl.m b/React/Views/RCTRefreshControl.m index 8b8638a2d94..a316246bcc1 100644 --- a/React/Views/RCTRefreshControl.m +++ b/React/Views/RCTRefreshControl.m @@ -89,7 +89,18 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)setTitle:(NSString *)title { - self.attributedTitle = [[NSAttributedString alloc] initWithString:title]; + NSRange range = NSMakeRange(0, self.attributedTitle.length); + NSDictionary *attrs = [self.attributedTitle attributesAtIndex:0 effectiveRange: &range]; + self.attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attrs]; +} + +- (void)setTitleColor:(UIColor *)color +{ + NSRange range = NSMakeRange(0, self.attributedTitle.length); + NSDictionary *attrs = [self.attributedTitle attributesAtIndex:0 effectiveRange: &range]; + NSMutableDictionary *attrsMutable = [attrs mutableCopy]; + [attrsMutable setObject:color forKey:NSForegroundColorAttributeName]; + self.attributedTitle = [[NSAttributedString alloc] initWithString:self.attributedTitle.string attributes:attrsMutable]; } - (void)setRefreshing:(BOOL)refreshing diff --git a/React/Views/RCTRefreshControlManager.m b/React/Views/RCTRefreshControlManager.m index bc479a150eb..cd5e1759149 100644 --- a/React/Views/RCTRefreshControlManager.m +++ b/React/Views/RCTRefreshControlManager.m @@ -24,5 +24,6 @@ RCT_EXPORT_VIEW_PROPERTY(onRefresh, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(refreshing, BOOL) RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor) RCT_EXPORT_VIEW_PROPERTY(title, NSString) +RCT_EXPORT_VIEW_PROPERTY(titleColor, UIColor) @end