我正在努力更改
UIImagePickerController
库类型的颜色。有人知道我做错了什么吗?不知道为什么它是黄色的,我只是想让它看起来更标准。
代码
private func getImage(fromSourceType sourceType: UIImagePickerController.SourceType) {
if UIImagePickerController.isSourceTypeAvailable(sourceType) {
let imagePickerController = UIImagePickerController()
imagePickerController.navigationBar.isTranslucent = false
imagePickerController.navigationBar.barTintColor = .white
imagePickerController.navigationBar.tintColor = .black
imagePickerController.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
imagePickerController.delegate = self
imagePickerController.sourceType = sourceType
self.parentViewController?.present(imagePickerController, animated: true, completion: nil)
}
}
结果
你检查过你的AppDelegate.swift吗?
如果你在 AppDelegate 中自定义了 UINavigationBar barTintColor,它也会影响 UIImagePicker 的 barTintColor:
UINavigationBar.appearance().barTintColor = UIColor(named: "yellow")
检查是否有类似上面的代码,删除它,barTintColor就会恢复默认颜色。