我以编程方式创建了一个带有范围栏的搜索控制器,但我无法更改范围栏的色调颜色。我使用以下代码创建了搜索控制器:
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
搜索栏还有一个取消按钮,我使用以下代码更改了色调颜色:
UIBarButtonItem.appearance(whenContainedInInstancesOf:[UISearchBar.self]).tintColor = UIColor.red
非常感谢你的帮助。