Reputation: 1656
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.delegate = self
UINavigationBar.appearance().tintColor = UIColor.white
UISearchBar.appearance.textField.setTextColor = UIColor.red
UISearchBar.appearance().barStyle = UIBarStyle.default
self.present(autocompleteController, animated: true, completion:nil)
Upvotes: 1
Views: 1439
Reputation: 1020
This one is worked for latest swift version
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white] as [String:Any]
Upvotes: 0
Reputation: 15758
Try this.
if #available(iOS 9.0, *) {
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSForegroundColorAttributeName: UIColor.green]
} else {
// Fallback on earlier versions
}
Upvotes: 5