如何在iOS 15&#x2B中修复Navbar UiimagePickerController保持透明
设备使用时,我对uiimagePickerController有问题
iOS 15 =“ https://i.sstatic.net/mdhab.jpg” alt =“在此处输入图像说明”> 我的期望是Navbar像15岁以下的iOS设备一样保持白色 我使用了此方法,但是它不起作用,有没有办法解决此问题?
let picker = UIImagePickerController()
picker.sourceType = .photoLibrary
picker.delegate = self
picker.modalPresentationStyle = .overCurrentContext
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .white
appearance.shadowColor = .white
appearance.shadowImage = UIImage()
picker.navigationBar.standardAppearance = appearance
picker.navigationBar.scrollEdgeAppearance = appearance
}
viewController.present(picker, animated: true, completion: nil)
谢谢
I have a problem with UIImagePickerController when used by iOS 15 device because the navigation bar has a transparent background,
my expectation is the navbar to stay white like on ios devices below 15
I've used this method but it doesn't work, is there a way to fix this issue?
let picker = UIImagePickerController()
picker.sourceType = .photoLibrary
picker.delegate = self
picker.modalPresentationStyle = .overCurrentContext
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .white
appearance.shadowColor = .white
appearance.shadowImage = UIImage()
picker.navigationBar.standardAppearance = appearance
picker.navigationBar.scrollEdgeAppearance = appearance
}
viewController.present(picker, animated: true, completion: nil)
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Apple论坛上的一些旧问题它的导航栏似乎参考
picker.navigationbar.standardappearance
无法真正更改Picker的外观,唯一不幸的解决方案是为所有uinavigationbars
全局更改外观,通过同样设置其外观:也可以 :检查您是否没有偶然地在代码中的某个地方修改全局显示。
希望它可以帮助您,即使它不是最佳解决方案。
According to some old question on Apple forum regarding
UIImagePickerController
and its navigationBar it seems that referencingpicker.navigationBar.standardAppearance
cannot really change picker appearence and the only unfortunate solution is to globally change appearence for allUINavigationBars
by setting its appearence likewise:Also check if you are not modifying the global appearence somewhere in your code by accident.
Hopefully it helps you, even though it is propably not optimal solution.