您的位置:首页 > 移动开发 > IOS开发

iOS 修改textholder的颜色

2014-04-02 20:57 267 查看
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, 50, 320, 50)];
textField.placeholder = @"填写订单";
if ([textField respondsToSelector:@selector(setAttributedPlaceholder:)]) {
UIColor *color = [UIColor redColor];
textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"填写订单" attributes:@{NSForegroundColorAttributeName: color}];
} else {
NSLog(@"Cannot set placeholder text's color, because deployment target is earlier than iOS 6.0");
// TODO: Add fall-back code to set placeholder color.
}
[self.view addSubview:textField];

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: