iOS13不再允许UITextField的placeholder属性通过 kvc 的方式更改颜色和字体等属性,替换方法为:
UITextField * searchField = self.searchTextField;
NSString *placeHolder = @"请输入关键词搜索";
NSMutableAttributedString *placeHolderStr = [[NSMutableAttributedString alloc]initWithString:placeHolder];
NSDictionary *attrDic = @{@"NSFontAttributeName":[UIFont systemFontOfSize:15],
@"NSForegroundColorAttributeName":[UIColor grayColor]};
[placeHolderStr addAttributes:attrDic} range:NSMakeRange(0, placeHolder.length)];
searchField.attributedPlaceholder = placeHolderStr;
网友评论