我有一个要设置白色背景的UISearchBar
。
由于要设置自定义边框,因此我为minimal
选择了searchBarStyle
值。
我可以通过将backgroundColor
和borderStyle
设置为searchTextField
来获得白色背景(此字段仅在iOS 13中可用,要在其他iOS版本中安全访问它,请检查here,如下所示:] >
,当searchBar.searchTextField.borderStyle = .none searchBar.searchTextField.backgroundColor = .white
但是,这在iOS 13中不起作用
searchBarStyle
值为minimal
时,背景色似乎被忽略了,但是对于default
/ prominent
样式正确地起作用。我有一个要设置白色背景的UISearchBar。由于我要设置自定义边框,因此我选择了searchBarStyle的最小值。我可以通过设置...
[试图弄清楚这一点时,我注意到在运行时使用searchBarStyle
更改Reveal时正确应用了背景色。