let cnPicker = CNContactPickerViewController()
cnPicker.delegate = self
self.present(cnPicker, animated: true, completion: nil)
取消和完成按钮为白色。
我需要将它们更改为黑色,找不到任何信息。
我该怎么做?
答案 0 :(得分:0)
确实如此,在当前
上更改UINavigationBar.appearance()
的条形tintcolor和tintcolor
let cnPicker = CNContactPickerViewController()
cnPicker.delegate = self
changeAppearance()
self.present(cnPicker, animated: true, completion: nil)
func changeAppearance() {
UINavigationBar.appearance().tintColor = .black
UINavigationBar.appearance().barTintColor = . black
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor:.black]
UINavigationBar.appearance().barStyle = .white // customize
}
关闭CNContactPickerViewController再次更改外观
func contactPickerDidCancel(_ picker: CNContactPickerViewController)
{
resetAppearance()
}
func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) {
resetAppearance()
}
func contactPicker(_ picker: CNContactPickerViewController, didSelect contactProperty: CNContactProperty) {
resetAppearance()
}
func resetAppearance() {
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().barTintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor:.black]
UINavigationBar.appearance().barStyle = .black // customize
}