小任班长的博客 - attributedPlaceholder 属性
type: channel
link: https://cnxiaocheng.top/tag/attributedPlaceholder-属性/
items: ios13 foeKeyPath不允许访问私有变量 崩溃 _placeholderLabel

ios13 foeKeyPath不允许访问私有变量 崩溃 _placeholderLabel
type: item
date: 2020-05-04T09:00:00+08:00
description: 下方代码在ios13 中会崩溃//[ self.contentTextField setValue:KRGBColor(154, 154, 154, 1.0) forKeyPath:@"_placeholderLabel.textColor"];//[ self.contentTextField setValue:[UIFont systemFontOfSize:13.0] forKeyPath:@"_placeholderLabel.font"];//UITextField *textfield = [[UITextField alloc]init];调整方法，通过attributedPlaceholder属性NSMutableAttributedString *arrStr = [[NSMutableAttributedString alloc]initWithString:self.contentTextField.placeholder attributes:@{NSForegroundColorAttributeName : KRGBColor(154, 154, 154, 1.0),NSFontAttributeName:[UIFont systemFontOfSize:13.0]}];self.contentTextField.attributedPlaceholder = arrStr;