方法一:
textField.placeholder = @"hello world !";
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont boldSystemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"]; textField.placeholder = @"username is in here!";
方法二:
UITextField * textField = [[UITextField alloc]initWithFrame:CGRectMake(30, 150, 260, 30)];
textField.borderStyle = UITextBorderStyleRoundedRect;
NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc]initWithString:@"string"];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, attributedStr.length)];
textField.textAlignment = NSTextAlignmentCenter;
textField.attributedPlaceholder = attributedStr;
[self.view addSubview:textField];