【发布时间】:2015-12-29 19:58:32
【问题描述】:
我在表格视图单元格上创建了一个文本字段。但我希望能够添加一个占位符。
【问题讨论】:
标签: swift uitableview uitextfield
我在表格视图单元格上创建了一个文本字段。但我希望能够添加一个占位符。
【问题讨论】:
标签: swift uitableview uitextfield
您可以使用检查面板中的占位符字段,如下所示。如果您想以编程方式执行此操作,可以使用与此类似的东西
//create the attribute dictionary
let placeholderAttr = [
NSForegroundColorAttributeName: UIColor.lightGrayColor(),
NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 22.0)!,
]
//apply the attributes to the placeholder
yourTextField.attributedPlaceholder = NSAttributedString(string: "This is your placeholder text", attributes: placeholderAttr)
yourTextField.textAlignment = NSTextAlignment.Left
【讨论】: