How to change color of CNContactPickerViewController searchBar
Asked Answered
A

1

9

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.

Aerostatics answered 11/9, 2017 at 18:24 Comment(4)
is this a bug or new in iOS11Internalcombustion
Since iOS 11 is out now, I think this is new in iOS11, depending on the tintcolor of your app.Aerostatics
I 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]];Explain
The correct solution for me was @MohamedElkassas's comment, [[UISearchBar appearance] setBackgroundColor:[UIColor whiteColor]];. This bug is only present in iOS 11, @RBN.Jehiah
A
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)
Ake answered 6/12, 2017 at 3:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.