【发布时间】:2017-02-10 09:17:46
【问题描述】:
我正在尝试通过在 viewDidLoad 中使用此代码,在表格视图中将搜索占位符更改为“搜索设备”:
let placeholderAttributes: [String : AnyObject] = [NSForegroundColorAttributeName: UIColor.blue, NSFontAttributeName: UIFont.systemFont(ofSize: UIFont.systemFontSize)]
let attributedPlaceholder: NSAttributedString = NSAttributedString(string: "Search for a Device", attributes: placeholderAttributes)
let textFieldPlaceHolder = searchBar.value(forKey: "searchField") as? UITextField
textFieldPlaceHolder?.attributedPlaceholder = attributedPlaceholder
我确定代码中一切正常,但是为什么占位符没有改变?!
【问题讨论】:
标签: ios swift tableview uisearchbar placeholder