我已经用谷歌搜索了几个小时如何更改我的 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)