-1

I'm still a novice for the most part and the code I'm working with is part of a company's app that has already been in development for a long time. I'm still learning and taking on the smaller jobs that can't be actively worked on. I'm still fairly clueless on many subjects. This is code that I have related to the search bar, I need to change the placeholder text color:

    func addSearchController() {
            // initialize searchResultsController set to nil as we want to use this view controller to display the search results
            searchController = UISearchController(searchResultsController: nil)
            searchController.searchResultsUpdater = self
            searchController.dimsBackgroundDuringPresentation = false
            searchController.searchBar.sizeToFit()
            searchController.searchBar.tintColor = .white
            searchController.searchBar.barTintColor = .ocTopGreen()
            searchController.searchBar.searchTextField.textColor = .white
            searchController.searchBar.placeholder = "Search for a symptom"
            tableView.tableHeaderView = searchController.searchBar
        }

Any assistance would be appreciated.

1 Answers1

0

If you want the placeholder's text formatting to be different than the input's text formatting, then you won't be able to do that using a placeholder.

Instead, you should create an element that acts like a placeholder. Simply position it where your placeholder would normally be. Have it disappear as soon as you detect that the inputbox is not empty.

  • There is placeholder text already present, it works correctly, I just need to figure out what code to throw in to change the color of said placeholder text. I may have misunderstood your response, and if I have, I apologize – WilsonRLackey Dec 12 '19 at 16:40
  • Oh if it's that simple: https://www.w3schools.com/howto/howto_css_placeholder.asp – DummyAccount Dec 12 '19 at 16:43