iOS 13 深色模式 Placeholder颜色适配

2019-10-29  本文已影响0人  仲夏丶初柒

深色模式主要是使用了因为使用了默认颜色 设置个颜色就好了比如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赋值之后了

上一篇 下一篇

猜你喜欢

热点阅读