Added placeholderTextColor property for TextInput class
Summary: Closes https://github.com/facebook/react-native/pull/997 Github Author: Maksim Bunkow <bimawa@gmail.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
parent
826b56a41b
commit
bae4e44c60
|
@ -445,6 +445,7 @@ var TextInput = React.createClass({
|
|||
onSubmitEditing={this.props.onSubmitEditing}
|
||||
onSelectionChangeShouldSetResponder={() => true}
|
||||
placeholder={this.props.placeholder}
|
||||
placeholderTextColor={this.props.placeholderTextColor}
|
||||
text={this.state.bufferedValue}
|
||||
autoCapitalize={autoCapitalize}
|
||||
autoCorrect={this.props.autoCorrect}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
@property (nonatomic, assign) BOOL autoCorrect;
|
||||
@property (nonatomic, assign) BOOL selectTextOnFocus;
|
||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||
@property (nonatomic, strong) UIColor *placeholderTextColor;
|
||||
|
||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
|
|
|
@ -42,6 +42,28 @@
|
|||
}
|
||||
}
|
||||
|
||||
static void RCTUpdatePlaceholder(RCTTextField *self)
|
||||
{
|
||||
if (self.placeholder.length > 0 && self.placeholderTextColor) {
|
||||
self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder
|
||||
attributes:@{
|
||||
NSForegroundColorAttributeName : self.placeholderTextColor
|
||||
}];
|
||||
} else if (self.placeholder.length) {
|
||||
self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor {
|
||||
_placeholderTextColor = placeholderTextColor;
|
||||
RCTUpdatePlaceholder(self);
|
||||
}
|
||||
|
||||
- (void)setPlaceholder:(NSString *)placeholder {
|
||||
super.placeholder = placeholder;
|
||||
RCTUpdatePlaceholder(self);
|
||||
}
|
||||
|
||||
- (NSArray *)reactSubviews
|
||||
{
|
||||
// TODO: do we support subviews of textfield in React?
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#import "RCTTextFieldManager.h"
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTShadowView.h"
|
||||
#import "RCTSparseArray.h"
|
||||
#import "RCTTextField.h"
|
||||
|
@ -28,6 +27,7 @@ RCT_EXPORT_VIEW_PROPERTY(caretHidden, BOOL)
|
|||
RCT_EXPORT_VIEW_PROPERTY(autoCorrect, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(placeholderTextColor, UIColor)
|
||||
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(clearButtonMode, UITextFieldViewMode)
|
||||
RCT_REMAP_VIEW_PROPERTY(clearTextOnFocus, clearsOnBeginEditing, BOOL)
|
||||
|
|
Loading…
Reference in New Issue