美文网首页
iOS开发修改UITextField的placeholder的颜

iOS开发修改UITextField的placeholder的颜

作者: 码农小白 | 来源:发表于2017-07-21 16:00 被阅读4次

贴上代码

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;

相关文章

网友评论

      本文标题:iOS开发修改UITextField的placeholder的颜

      本文链接:https://www.haomeiwen.com/subject/vfeekxtx.html