简体   繁体   English

Google Place Picker搜索栏文本颜色不变iOS Swift

[英]Google Place Picker Search Bar text Color not Change iOS Swift

This is my Code Please review 4th line where i set color but it will show me Error 这是我的代码,请检查我设置颜色的第四行,但它会向我显示错误

 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)

Try this. 尝试这个。

if #available(iOS 9.0, *) {
  UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSForegroundColorAttributeName: UIColor.green]
  } else {
  // Fallback on earlier versions
}

此版本适用于最新的Swift版本

UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white] as [String:Any]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM