在UITextField中没有属性设置placeholder的颜色,在网上找了一下,有两个方法能修改颜色。
方法一:
比较简单的一句代码搞定:[_textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
方法二:
继承UITextField并且重写draw方法
//控制placeHolder的颜色、字体
- (void)drawPlaceholderInRect:(CGRect)rect
{
[[UIColor grayColor] setFill];
[[self placeholder] drawInRect:rectwithFont:[UIFont systemFontOfSize:20]];
}