贴上代码
UITextField *textField = [UITextField new];
NSString *placeHolderStr = @"我是placeholder";
textField.placeholder = placeHolderStr;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:placeHolderStr];
[placeholder addAttribute:NSForegroundColorAttributeName
value:[UIColor whiteColor]
range:NSMakeRange(0, placeHolderStr.length)];
[placeholder addAttribute:NSFontAttributeName
value:[UIFont boldSystemFontOfSize:16]
range:NSMakeRange(0, placeHolderStr.length)];
textField.attributedPlaceholder = placeholder;
网友评论