修改placeholder的大小和颜色

效果图

Paste_Image.png

代码

    static func textFieldPlaceholder(textField: UITextField, message: String) {
        textField.attributedPlaceholder = NSAttributedString(string:message,attributes:[NSForegroundColorAttributeName: UIColor.whiteColor()])
    }
// 引用
  Tools.textFieldPlaceholder(findPwdByPhoneTextField, message: "请输入手机号码")
    private lazy var couponTextFiled: UITextField = {
        let couponTextFiled = UITextField()
        couponTextFiled.keyboardType = .NumberPad
        couponTextFiled.borderStyle = .RoundedRect
        couponTextFiled.autocorrectionType = .No
        couponTextFiled.font = UIFont.systemFontOfSize(14)
        let placeholder = NSAttributedString(string: "请输入优惠劵号码", attributes: [NSFontAttributeName : UIFont.systemFontOfSize(14), NSForegroundColorAttributeName : UIColor(red: 50 / 255.0, green: 50 / 255.0, blue: 50 / 255.0, alpha: 0.8)])
        couponTextFiled.attributedPlaceholder = placeholder
        return couponTextFiled
    }()
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容