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:
Valentin Shergin 2017-05-29 15:56:41 -07:00 committed by Facebook Github Bot
parent ea9d6746df
commit 1018cc8ceb
1 changed files with 13 additions and 10 deletions

View File

@ -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];
}