iOS开发修改UITextField的placeholder的颜色字体大小等

来源:互联网 发布:越前南次郎的实力数据 编辑:程序博客网 时间:2024/06/05 11:00

贴上代码

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;
1 0
原创粉丝点击