UITextField placeholder 改变默认字体颜色
2015-12-17 18:20
411 查看
这么基础的东西居然还要找好一会,做个记录:
继承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()])
继承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()])
相关文章推荐
- Apple Swift学习教程
- 介绍 Fedora 上的 Swift
- Swift中实现点击、双击、捏、旋转、拖动、划动、长按手势的类和方法介绍
- Swift编程中的泛型解析
- Swift中定义二维数组的方法及遍历方法示例
- 简单分析Swift语言的一些基本特征
- Swift与C语言指针结合使用实例
- Swift心得笔记之控制流
- 用Swift构建一个简单的iOS邮件应用的方法
- 苹果公司推出的新编程语言Swift简介和入门教程
- 探讨Swift数组和字典
- Swift中的指针操作和使用详细介绍
- Swift中使用正则表达式的一些方法
- Swift心得笔记之运算符
- Swift中使用可选类型完美解决占位问题
- Swift学习笔记之构造器重载
- Swift中的Access Control权限控制介绍
- Swift类型创建之自定义一个类型详解
- Swift教程之控制流详解