У меня возникли проблемы с настройкой цветов кнопок навигации в PHPickerViewController, когда он отображается с ограниченным доступом к библиотеке фотографий на iOS. Кнопки панели навигации («Отмена» и «Готово») отображаются белым цветом на белом фоне, что делает их невидимыми. Я хочу, чтобы они отображались черным для лучшей видимости.
Что я пробовал:
- Настройка глобального внешнего вида UINavigationBar в AppDelegate:
Код: Выделить всё
UINavigationBar.appearance().tintColor = UIColor.black
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .white
appearance.titleTextAttributes = [.foregroundColor: UIColor.black]
appearance.buttonAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.black]
appearance.shadowColor = .clear
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
- Непосредственная настройка PHPickerViewController:
Код: Выделить всё
@objc func openPHPicker() {
if #available(iOS 14.0, *) {
var configuration = PHPickerConfiguration()
configuration.selectionLimit = 4
configuration.filter = .images
let picker = PHPickerViewController(configuration: configuration)
picker.navigationController?.navigationBar.tintColor = .black
picker.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.black]
picker.delegate = self
self.present(picker, animated: true, completion: nil)
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... ary-picker
Мобильная версия