您的位置:首页 > 产品设计 > UI/UE

UITextField placeholder 改变默认字体颜色

2015-12-17 18:20 411 查看
这么基础的东西居然还要找好一会,做个记录:

继承UITextField

class GsTextField: UITextField {

}


override func drawPlaceholderInRect(rect: CGRect) {
if let placeholders = placeholder{
self.attributedPlaceholder =
NSAttributedString(string: placeholders,
attributes: [NSForegroundColorAttributeName:UIColor.whiteColor()])
}
super.drawPlaceholderInRect(rect)
}

或者在外面调用直接写

self.mTextField.attributedPlaceholder =NSAttributedString(string: placeholders, attributes: [NSForegroundColorAttributeName:UIColor.whiteColor()])
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  swift