0

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 enter image description here C in normal mode enter image description here B after pushing C goes back and present B enter image description here here the searchTextfield textColor is white. and want it black.

Yoel Jimenez del valle
  • 1,270
  • 1
  • 9
  • 20
  • Looks like you are changing the tint color of the navigation bar in C. Mind that they are all the same navigation bar unless you intentionally change controllers. – Desdenova Jun 02 '22 at 13:45
  • yes in c is changed but B is presented not pushed, so no navigationController for B, unless im wrong – Yoel Jimenez del valle Jun 02 '22 at 13:55

1 Answers1

0

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
Deep Gandhi
  • 157
  • 1
  • 4
  • 13
  • the name is correct checked several times. if not pushed C the text color is supportDarkest after pushing C go back and present B the text color became white because C has a UINavigationApparence to use text color in white, and for some reason that value get passed to B even when B has not Navigation controller or any like that. – Yoel Jimenez del valle Jun 03 '22 at 14:28
  • same result red first before pushing c and white after go back and present B – Yoel Jimenez del valle Jun 03 '22 at 14:43
  • setup barStyle didn't work either? – Deep Gandhi Jun 04 '22 at 12:59