![](/img/trans.png)
[英]UIImagePickerController that allowsEditing incorrectly crops the image leaving a black bar across the top
[英]UIImagePickerController returns image with black background on right side when the property .allowsEditing is set to true
我正在使用 UIImagePickerController 从图库中挑选图像。 这是代码
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
imagePicker.delegate = self
self.present(imagePicker, animated: true, completion: nil)
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
isfrompicker = true
if let image = info[.editedImage] as? UIImage {
// I'm getting image with black background on right side as shown.
}
}
我不确定为什么我在右侧得到黑色背景。 相同的代码在某些设备上运行良好。 但是我的 iPhone X 出现了问题。
几年前我遇到了同样的问题。 然后我在链接到页面上找到了解决方案
在呈现 imagePicker 之前尝试添加此行
UINavigationBar.appearance().isTranslucent = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.