改变UITextField的 placeHolder颜色的方法

来源:互联网 发布:telnet端口23链接失败 编辑:程序博客网 时间:2024/04/29 04:09

 方法一:

[_textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];

方法二:

         继承UITextField并且重写draw方法

            //控制placeHolder的颜色、字体
           - (void)drawPlaceholderInRect:(CGRect)rect
           {
                  [[UIColor grayColor] setFill];
                  [[self placeholder] drawInRect:rectwithFont:[UIFont systemFontOfSize:20]];
           }

0 0