I created a search controller with a scope bar programmatically and I couldn't change the scope bar's tint color. I created the search controller with the following code:
我以编程方式创建了一个带有范围栏的搜索控制器,但我无法更改范围栏的色调颜色。我使用以下代码创建了搜索控制器:
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search Buildings or Codes"
navigationItem.searchController = searchController
definesPresentationContext = true
searchController.searchBar.scopeButtonTitles = ["Building Names", "Building Codes"]
searchController.searchBar.delegate = self
There is also a cancel button for the search bar and I changed the tint color using this code:
搜索栏还有一个取消按钮,我使用以下代码更改了色调颜色:
UIBarButtonItem.appearance(whenContainedInInstancesOf:[UISearchBar.self]).tintColor = UIColor.red
Thank you so much for your help.
非常感谢你的帮助。