当前位置:首页 > 移动开发 > 正文

第38月第8天 ios13 _placeholderLabel

2024-03-31 移动开发

1.

"NSGenericException" - reason: "Access to UITextField‘s _placeholderLabel ivar is prohibited. This is an application bug"

设置TextFiled的默认文字颜色在iOS13 Crash。

[textfield setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
 查了一下,帖子挺多的,解决方案:

Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel");
UILabel *placeholderLabel = object_getIvar(textField, ivar);
placeholderLabel.textColor = [UIColor whiteColor];
记得加头文件

#import <objc/runtime.h>

 

https://blog.csdn.net/Han_Laomo/article/details/101111427

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/yidong/18205.html