Skip to content

Instantly share code, notes, and snippets.

@marinat
Created September 17, 2018 08:56
Show Gist options
  • Save marinat/a42d0c75a7fef084c2ebff22bda20e03 to your computer and use it in GitHub Desktop.
Save marinat/a42d0c75a7fef084c2ebff22bda20e03 to your computer and use it in GitHub Desktop.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let searchController = UISearchController(searchResultsController: nil)
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white]
if let textfield = searchController.searchBar.value(forKey: "searchField") as? UITextField {
//let ss = sw?.subviews
if let backgroundview = textfield.subviews.first {
// Background color
backgroundview.backgroundColor = hexStringToUIColor(hex: "#8392B0")
}
}
navigationItem.searchController = searchController
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment