gpt4 book ai didi

swift - UISearchController searchBar 不更新 barTintColor

转载 作者:行者123 更新时间:2023-11-28 07:40:11 26 4
gpt4 key购买 nike

我正在尝试使用波纹管代码更新搜索栏外观。

    searchController.searchBar.searchBarStyle = .prominent
searchController.searchBar.backgroundColor = UIColor.clear
searchController.searchBar.barTintColor = UIColor.black

它不会改变颜色。

最佳答案

或者您可以创建一个搜索栏导出并执行:-

@IBOutlet weak var searchBar: UISearchBar!
searchBar.barTintColor = UIColor.black;

或者你想创建自定义:-

var searchBar: UIView = UIView()
var searchField: UISearchBar = UISearchBar();

searchBar.frame = CGRect(x: 0, y: 0, width: xxx, height: xxx)
searchField.barTintColor = UIColor.black;
searchField.frame = CGRect(x: searchBar.frame.origin.x, y: searchBar.frame.origin.y, width: xxx, height: searchBar.frame.height)
searchField.tintColor = UIColor.black
searchBar.addSubview(searchField)

关于swift - UISearchController searchBar 不更新 barTintColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52497795/

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