【发布时间】:2019-10-24 07:16:42
【问题描述】:
当我更改 UISearchBar 中文本字段的背景颜色时,我发现颜色设置不正确。例如:我设置了颜色#2B2F6A,但它变成了#343869。
对此有什么建议吗?非常感谢。
Code:
iOS < 13
if let textField = self.value(forKey: "searchField") as? UITextField {
if let backgroundView = textField.subviews.first {
backgroundView.backgroundColor = UIColor(red: 28.0/255.0, green: 28.0/255.0, blue: 28.0/255.0, alpha: 1.0)
}
}
iOS 13:
self.searchTextField.backgroundColor = UIColor(red: 28.0/255.0, green: 28.0/255.0, blue: 28.0/255.0, alpha: 1.0)
设置的颜色可能是灰色,但结果看起来像黑色
【问题讨论】:
-
你在哪个 iOS 版本上检查这个?
-
设置颜色后能否提供一些示例代码?