mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-13 09:20:50 +08:00
Allow to set refresh control title color
Summary:Closes #6812  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:
committed by
Facebook Github Bot 3
parent
083bad44b2
commit
849a0f31ac
@@ -94,6 +94,7 @@ const RefreshControlExample = React.createClass({
|
||||
onRefresh={this._onRefresh}
|
||||
tintColor="#ff0000"
|
||||
title="Loading..."
|
||||
titleColor="#00ff00"
|
||||
colors={['#ff0000', '#00ff00', '#0000ff']}
|
||||
progressBackgroundColor="#ffff00"
|
||||
/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user