gpt4 book ai didi

ios - 颜色未正确设置到搜索栏

转载 作者:行者123 更新时间:2023-12-01 19:30:25 24 4
gpt4 key购买 nike

我正在这样设置我的搜索栏...

    self.searchBar.placeholder = "Search Plants"
searchBar.layer.cornerRadius = 5
searchBar.clipsToBounds = true
searchBar.barTintColor = UIColor(red:255/255, green:127/255, blue:0, alpha:1)


if let textField = self.searchBar.subviews.first?.subviews.compactMap({ $0 as? UITextField }).first {
textField.subviews.first?.isHidden = true
textField.layer.backgroundColor = UIColor.white.cgColor

textField.layer.cornerRadius = 10
textField.layer.masksToBounds = true
}
现在,当我在iPhone 7上运行该项目时,它看起来像这样……
enter image description here
但是当我在iPhone XR上运行它时,看起来就像是...
enter image description here
这可能是什么原因...?

最佳答案

默认情况下,searchBar.searchTextField具有稍微不透明的背景颜色,因此为了防止tintColor渗色,我们需要显式设置颜色。

searchBar.searchTextField.backgroundColor = .white

关于ios - 颜色未正确设置到搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63147941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com