UITextField限制输入长度,修改placeholder颜色和大小
一.修改placeholder的字体大小和颜色 iOS 6 之前使用KVC改变placeholder的字体颜色和大小 [textField setValue:[UIColor redColor]forKeyPath:@"_placeholderLabel.textColor"]; [textField setValue:[UIFontboldSystemFontOfSize:14]forKeyPath:@"_placeholderLabel.font"]; iOS6之后还可以使用attributedPlaceholder来设置 UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 200, 200)]; NSString *holderText = @"hello world!"; NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:holderText]; [placeholder addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,