我正在尝试更改 UISearchbar 的背景颜色。我可以将背景设置为除白色之外的任何颜色。不知道为什么白色没有凝固。我正在使用下面的代码片段来设置颜色。我有一个扩展方法来获取文本字段。因此,您可以假设 textField 存在。
searchBar.backgroundColor = .white
searchBar.textField?.backgroundColor = .white
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用白色以外的颜色,它会显示该颜色。
searchBar.textField?.backgroundColor = .blue
Run Code Online (Sandbox Code Playgroud)
知道这里出了什么问题吗?