// UITextField扩展
import UIKit
extension UITextField {
/// UITextField占位文字修改
///
/// - Parameters:
/// - placeHolderStr: 占位文字
/// - withFont: 文本大小
/// - withColor: 文本颜色
func placeHolderChange(_ placeHolderStr : String,_ withFont : UIFont,_ withColor : UIColor) {
let attributes = [
NSAttributedStringKey.foregroundColor: withColor,
NSAttributedStringKey.font : withFont // Note the !
] as [NSAttributedStringKey : Any]
attributedPlaceholder = NSAttributedString(string: placeHolderStr, attributes:attributes)
}
}
网友评论