ios修改textField的placeholder的字体颜色大小

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 20, 200, 40)];
NSString *holderText = @"请输入用户名";
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:holderText];
[placeholder addAttribute:NSForegroundColorAttributeName
                  value:[UIColor redColor]
                  range:NSMakeRange(0, holderText.length)];
[placeholder addAttribute:NSFontAttributeName
                  value:[UIFont boldSystemFontOfSize:16]
                  range:NSMakeRange(0, holderText.length)];
textField.attributedPlaceholder = placeholder;
[cell.contentView addSubview:textField];
 

你可能感兴趣的:(ios)