I start a CNContactPickerViewController from a viewcontroller, but how can I change the textcolor of the searchbar inside it. The navigationbar is dark blue, in iOS11 the default searchbartext is black.
Asked
Active
Viewed 1,504 times
9
-
is this a bug or new in iOS11 – RBN Oct 30 '17 at 06:27
-
Since iOS 11 is out now, I think this is new in iOS11, depending on the tintcolor of your app. – tmiedema Oct 30 '17 at 08:43
-
1I didn't find a way to change the text color of searchbar it stays black but I managed to change the background color instead [[UISearchBar appearance] setBackgroundColor:[UIColor whiteColor]]; – Mohamed Elkassas Nov 14 '17 at 19:17
-
The correct solution for me was @MohamedElkassas's comment, `[[UISearchBar appearance] setBackgroundColor:[UIColor whiteColor]];`. This bug is only present in iOS 11, @RBN. – paulvs Jan 24 '18 at 19:31
1 Answers
3
I updated the way to fix in swift Before you present CNContactPickerViewController, you should set background color of UISearchBar
UISearchBar.appearance().backgroundColor = UIColor.white
let cancelButtonAttributes = [NSForegroundColorAttributeName: ColorConstant.baseColorGray]
UIBarButtonItem.appearance(whenContainedInInstancesOf:
[UISearchBar.self]).setTitleTextAttributes(cancelButtonAttributes, for: .normal)

Tran Trung Hieu
- 191
- 2
- 5