Building off @Synmax answer, I've put together this category you can use to add a placeholder text color to a UITextField:
@interface UITextField (Placeholder)
@property UIColor* placeholderTextColor;
@end
@implementation UITextField (Placeholder)
-(UIColor*)placeholderTextColor {
return [self.attributedPlaceholder attribute:NSForegroundColorAttributeName atIndex:0 effectiveRange:nil];
}
-(void)setPlaceholderTextColor:(UIColor*)placeholderTextColor {
if(self.attributedPlaceholder) {
NSMutableAttributedString* as = [[NSMutableAttributedString alloc] initWithAttributedString:self.attributedPlaceholder];
if(placeholderTextColor) {
[as setAttributes:[NSDictionary dictionaryWithObject:placeholderTextColor forKey:NSForegroundColorAttributeName] range:NSMakeRange(0, self.attributedPlaceholder.length)];
} else {
[as removeAttribute:NSForegroundColorAttributeName range:NSMakeRange(0, self.attributedPlaceholder.length)];
}
self.attributedPlaceholder = as;
} else if(self.placeholder) {
self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder attributes:[NSDictionary dictionaryWithObject:placeholderTextColor forKey:NSForegroundColorAttributeName]];
}
}
@end
You can then set the placeholder text color using appearance like this...
[UITextField appearance].placeholderTextColor = UIColor.grayColor;