我UISearchBar
在的顶部添加了PFQueryTableViewController
。我已经将searchBar的颜色更改为我的应用程序的颜色,但是这样做似乎也将其右侧的“取消”按钮的颜色更改为相同的颜色。理想情况下,我希望颜色为白色。
此图显示了当前的外观:
看起来好像没有“取消”按钮,但是它的颜色与searchBar相同(您仍然可以按其,依此类推)
我有办法将“取消”按钮的颜色更改为白色吗?我尝试过的一切似乎都没有什么不同。
Code i've used to make the UISearchBar
this colour is:
UISearchBar.appearance().barTintColor = UIColor(hue: 359/360, saturation: 67/100, brightness: 71/100, alpha: 1)
UISearchBar.appearance().tintColor = UIColor(hue: 359/360, saturation: 67/100, brightness: 71/100, alpha: 1)
And in the storyboard i've set these:
And finally, to make the placeholder, and text white inside the SearchBar, i've used:
for subView in self.filmSearchBar.subviews {
for subsubView in subView.subviews {
if let searchBarTextField = subsubView as? UITextField {
searchBarTextField.attributedPlaceholder = NSAttributedString(string: NSLocalizedString("Search Cinevu film reviews", comment: ""), attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()])
searchBarTextField.textColor = UIColor.whiteColor()
}
}
}
Thanks for any help! :)
Having a look around, this seemed to be the best way to achieve what I needed:
let cancelButtonAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes , for: .normal)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句