'ImagePicker' 类型的值没有成员 'contentMode'

Value of type 'ImagePicker' has no member 'contentMode'

我正在尝试使用下面列出的 contentMode,但我不明白为什么会收到以下错误:

无法推断引用成员的上下文基础 'scaleAspectFit' 类型 'ImagePicker' 的值没有成员 'contentMode'

           if let uiImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
               parent.contentMode = .scaleAspectFit    <--- Error
               parent.image = uiImage
           }
           
           parent.presentationMode.wrappedValue.dismiss()
       }
   }

有什么提示吗? 谢谢!

附上完整代码:

struct ImagePicker: UIViewControllerRepresentable {
    @Environment(\.presentationMode) var presentationMode
    @Binding var image: UIImage?
    
    func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController {
        let picker = UIImagePickerController()
        picker.delegate = context.coordinator
        picker.allowsEditing = true
        
    //    picker.mediaTypes = ["public.image"]
        return picker
    }
    
    func updateUIViewController(_ uiViewController: UIImagePickerController, context: UIViewControllerRepresentableContext<ImagePicker>) {}
    
    class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
        let parent: ImagePicker
        
        init(_ parent: ImagePicker) {
            self.parent = parent
        }
        
        func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
            if let uiImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
                parent.image.contentMode = .scaleAspectFit
                parent.image = uiImage
            }
            
            parent.presentationMode.wrappedValue.dismiss()
        }
    }
    
    func makeCoordinator() -> Coordinator {
        Coordinator(self)
    }
}

添加contentMode 属性

struct ImagePicker: UIViewControllerRepresentable {
   @Environment(\.presentationMode) var presentationMode
   @Binding var image: UIImage? 
   @Binding var mode:UIView.ContentMode? // here

然后

parent.mode = .scaleAspectFit