2016-10-07 14 views
2

私はGMSAutocompleteViewControllerを使用していますが、searchBarのtextColorを変更したいが、それを行う方法が見つからない場合は、 searchBarテキストGMSAutocompleteViewController iOS、searchBarのテキストの色を変更する方法

enter image description here

私は、次のコードを試してみたが、色は変更されません。

 acController.searchBarController?.searchBar.tintColor = UIColor.whiteColor() 
     acController.searchBarController?.searchBar.textColor = UIColor.whiteColor() 

     acController.searchBarController?.searchBar.textField.textColor = UIColor.whiteColor() 
     acController.searchBarController?.searchBar.textField.tintColor = UIColor.whiteColor() 
     acController.searchBarController?.searchBar.textField.backgroundColor = UIColor.whiteColor() 

     acController.searchDisplayController?.searchBar.setTextColor(UIColor.whiteColor()) 
     acController.searchDisplayController?.searchBar.tintColor = UIColor.whiteColor() 

     // changes the color of the sugested places 
     acController.primaryTextColor = UIColor.whiteColor() 
     acController.secondaryTextColor = UIColor.whiteColor() 
+1

あなたの問題を解決してみてください? –

答えて

2

は、このコード

let searchBarTextAttributes: [String : AnyObject] = [NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont.systemFontOfSize(UIFont.systemFontSize())] 
UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).defaultTextAttributes = searchBarTextAttributes 
関連する問題