Skip to content

Commit

Permalink
Allow to set refresh control title color
Browse files Browse the repository at this point in the history
Summary:Closes facebook#6812

![simulator screen shot 14 apr 2016 12 13 36](https://cloud.githubusercontent.com/assets/1488195/14521441/0abccf5c-0232-11e6-94dc-0ebdbfac4b3f.png)
Closes facebook#6970

Differential Revision: D3189244

fb-gh-sync-id: 7625b6ab5859aaa20bc0cb379855c5daeb584abf
fbshipit-source-id: 7625b6ab5859aaa20bc0cb379855c5daeb584abf
  • Loading branch information
skv-headless authored and zebulgar committed Jun 18, 2016
1 parent 2424db6 commit df8646a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions Examples/UIExplorer/RefreshControlExample.js
Expand Up @@ -94,6 +94,7 @@ const RefreshControlExample = React.createClass({
onRefresh={this._onRefresh}
tintColor="#ff0000"
title="Loading..."
titleColor="#00ff00"
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor="#ffff00"
/>
Expand Down
5 changes: 5 additions & 0 deletions Libraries/Components/RefreshControl/RefreshControl.js
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion React/Views/RCTRefreshControl.m
Expand Up @@ -89,7 +89,18 @@ - (NSString *)title

- (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
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTRefreshControlManager.m
Expand Up @@ -24,5 +24,6 @@ - (UIView *)view
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

0 comments on commit df8646a

Please sign in to comment.