美文网首页
iOS 13 深色模式 Placeholder颜色适配

iOS 13 深色模式 Placeholder颜色适配

作者: 仲夏丶初柒 | 来源:发表于2019-10-29 10:42 被阅读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赋值之后了

    相关文章

      网友评论

          本文标题:iOS 13 深色模式 Placeholder颜色适配

          本文链接:https://www.haomeiwen.com/subject/hgswvctx.html