How to get the crop rect of UIImagePickerController?

54 Views Asked by At

I want to draw over the imagePicker image section. I know that the image picker has an overlay view which you can use. However I want to add to the image section area only, so I need to get the crop rect.

I know there is a value in ImagePicker:

UIImagePickerController.InfoKey.cropRect

However I don't know how to access it and how to get the value out of it.

1

There are 1 best solutions below

0
benc On

The brief answer is:

UIImagePickerControllerEditedImage or editedImage

https://developer.apple.com/documentation/uikit/uiimagepickercontrollereditedimage?language=objc

Sample code, Swift 4.x

From long ago, I had found Xcode to be finicky about the swift version, so even though I used Swift, I use the O-C naming. Here's the code in my projects:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String:Any]) {
    print("Selected Image's MetaData: \(info)")
    if let image = info["UIImagePickerControllerEditedImage"] as? UIImage {

(blah blah blah)