Object-c 修改placeholder 文字顏色
阿新 • • 發佈:2020-12-16
技術標籤:OC學習
以前:
[self.nameTextField setValue:UIColorFromRGB(0x666666) forKeyPath:@"_placeholderLabel.textColor"];
新版:
#import <objc/runtime.h>
Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel"); UILabel *placeholderLabel = object_getIvar(self.searchTF, ivar); placeholderLabel.textColor = UIColorFromRGB(0x666666);