PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 6, 2022

[FIXED] How to change color of navigation bar of CNContactPickerViewController?

 November 06, 2022     contacts, ios, swift, uinavigationbar     No comments   

Issue

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)

Solution

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]


Answered By - mohammed.r.ghate
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,205,293

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing