我已经在Google上花费了几个小时来更改UISearchBar的字体大小和颜色,但是我无法找到与其相关的任何文档。
到目前为止,这是我在Swift 4上所做的:
searchBar = UISearchBar(frame: CGRect(x: 0, y: 0, width: view.frame.width - (menuImage.frame.width + iconImage.frame.width + 55), height: 30))
searchBar.placeholder = "SEARCH BAR"
searchBar.tintColor = UIColor.gray
searchBar.delegate = self
searchBar.font = [UIFont fontWithName:@"Oswald" size:11];
但这给了我一个错误。
您能告诉我如何更改UISearchBar的字体大小和颜色吗?
请帮忙!!!
更改文本和占位符搜索栏:
// SearchBar text
let textFieldInsideUISearchBar = searchBar.value(forKey: "searchField") as? UITextField
textFieldInsideUISearchBar?.textColor = UIColor.red
textFieldInsideUISearchBar?.font = textFieldInsideUISearchBar?.font?.withSize(12)
// SearchBar placeholder
let labelInsideUISearchBar = textFieldInsideUISearchBar!.value(forKey: "placeholderLabel") as? UILabel
labelInsideUISearchBar?.textColor = UIColor.red
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句