I want to change color of navigation bar shows on CNContactPickerViewController
.
I have tried the following code, but it doesn't work.
let contactPicker = CNContactPickerViewController()
// let searchController = UISearchController()
contactPicker.delegate = self
contactPicker.modalPresentationStyle = .fullScreen
// UISearchBar.appearance().text = "SEARCH".localized
// contactPicker.navigationController?.isNavigationBarHidden = true
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().barTintColor = .white
contactPicker.displayedPropertyKeys =
[CNContactPhoneNumbersKey, CNContactEmailAddressesKey]
contactPicker.predicateForEnablingContact = NSPredicate(format: "emailAddresses.@count > 0 || phoneNumbers.@count > 0")
present(contactPicker, animated: true)
If you want to change the color of the text in navigationBar just add these lines to willConnectTo method inside SceneDelegate file:
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().barTintColor = .orange
UINavigationBar.appearance().tintColor = .yellow
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.purple]
UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.purple]