Allow to set refresh control title color

Summary:Closes #6812

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

Differential Revision: D3189244

fb-gh-sync-id: 7625b6ab5859aaa20bc0cb379855c5daeb584abf
fbshipit-source-id: 7625b6ab5859aaa20bc0cb379855c5daeb584abf
This commit is contained in:
Sokovikov 2016-04-16 15:14:50 -07:00 committed by Facebook Github Bot 3
parent 083bad44b2
commit 849a0f31ac
4 changed files with 19 additions and 1 deletions

View File

@ -94,6 +94,7 @@ const RefreshControlExample = React.createClass({
onRefresh={this._onRefresh}
tintColor="#ff0000"
title="Loading..."
titleColor="#00ff00"
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor="#ffff00"
/>

View File

@ -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

View File

@ -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

View File

@ -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