深色模式主要是使用了因为使用了默认颜色 设置个颜色就好了比如RGB(204, 204, 204)
写个分类 就不用一个个去设置了
#import "UITextField+PlaceholderColor.h"
@implementation UITextField (PlaceholderColor)
- (void)setPlaceholder:(NSString *)placeholder{
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName:[UIColor redColor], NSFontAttributeName:self.font}];
self.attributedPlaceholder = attrString;
}
@end
并不影响单独设置某个placeholder的颜色 当然要注意只能在placeholder赋值之后了
网友评论