![](/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.