vickate_iOS_UITextField 的占位符自定义设置

来源:互联网 发布:学网络营销好还是java 编辑:程序博客网 时间:2024/06/03 15:10

富文本方法

@property (weak, nonatomic) IBOutlet UITextField *textField; NSDictionary *dic = @{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:15]}; self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Hello_Wrold!" attributes:dic]; self.textField.tintColor = [UIColor cyanColor];

KVC方法

self.textField.placeholder = @"Hello_Wrold!"; [self.textField setValue:[UIColor magentaColor] forKeyPath:@"_placeholderLabel.textColor"] [self.textField setValue:[UIFont systemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"]; self.textField.tintColor = [UIColor greenColor];
0 0