Reputation: 1278
have the following setup a root TabBarController the second index have a navigation bar that holds a viewController, for clarity call viewController A, a have a button to modal present a view controller with have a tableview, this tableview has as header a search controller search bar, lets call this viewController B, A viewController has another button to push a new view controller lest call C. C has a searchBar and navigation items is set to text color of search bar to be white.
if do A -> B, B searchController searchBar text color is black. if I go A -> C then go back and A -> B then B searchController searchBar text color is white like C.
tried to set the text color like in `viewDidLoad this but not result
if #available(iOS 13.0, *) {
searchController.searchBar.searchTextField.textColor = UIColor(named: "supportDarkest")
}
searchController.searchBar.tintColor = UIColor(named: "supportDarkest")
set this in viewWillAppear but nothing change.
override func viewWillAppear(_ animated: Bool) {
if #available(iOS 13.0, *) {
searchController.searchBar.searchTextField.textColor = UIColor(named: "supportDarkest")
searchController.searchBar.tintColor = UIColor(named: "supportDarkest")
searchController.searchBar.tintColorDidChange()
}
}
B in normal textColor
C in normal mode
B after pushing C goes back and present B
here the searchTextfield textColor is white. and want it black.
Upvotes: 0
Views: 479
Reputation: 395
It should work, check supportDarkest name is same as per assets. or try to check with any system color first like:
searchController.searchBar.searchTextField.textColor = .red
or you can try this too:
searchController.searchBar.barStyle = .black
Upvotes: 0