Small code style related change in -[RCTTextField updatePlaceholder]
Summary: Because we believe in Objective-C. Reviewed By: javache Differential Revision: D5070920 fbshipit-source-id: 17e2335c829f2e5857981c5028e3bcecbe5dc13f
This commit is contained in:
parent
ea9d6746df
commit
1018cc8ceb
|
@ -149,28 +149,31 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
}
|
||||
}
|
||||
|
||||
static void RCTUpdatePlaceholder(RCTTextField *self)
|
||||
- (void)updatePlaceholder
|
||||
{
|
||||
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];
|
||||
if (self.placeholder == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableDictionary *attributes = [NSMutableDictionary new];
|
||||
if (self.placeholderTextColor) {
|
||||
[attributes setObject:self.placeholderTextColor forKey:NSForegroundColorAttributeName];
|
||||
}
|
||||
|
||||
self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder
|
||||
attributes:attributes];
|
||||
}
|
||||
|
||||
- (void)setPlaceholderTextColor:(UIColor *)placeholderTextColor
|
||||
{
|
||||
_placeholderTextColor = placeholderTextColor;
|
||||
RCTUpdatePlaceholder(self);
|
||||
[self updatePlaceholder];
|
||||
}
|
||||
|
||||
- (void)setPlaceholder:(NSString *)placeholder
|
||||
{
|
||||
super.placeholder = placeholder;
|
||||
RCTUpdatePlaceholder(self);
|
||||
[self updatePlaceholder];
|
||||
[self updateIntrinsicContentSize];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue