iOS 13 之后直接通过以下方式修改Textfield的时候会出现报错信息
[_accountText setValue:Color_666666 forKeyPath:@"_placeholderLabel.textColor"];
报错信息
Access to UITextField’s _placeholderLabel ivar is prohibited. This is an application bug
解决方式
NSMutableAttributedString *passwordPlaceholderString = [[NSMutableAttributedString alloc] initWithString:@"账号密码" attributes:@{NSForegroundColorAttributeName : Color_666666}];
_passwordText.attributedPlaceholder = passwordPlaceholderString;
本文介绍在iOS13及以后版本中修改UITextField时出现的错误:_accountTextsetValue:Color_666666forKeyPath:@_placeholderLabel.textColor,并提供了一种解决该问题的方法,使用NSAttributedString设置占位符颜色。
1865

被折叠的 条评论
为什么被折叠?



