Force UIImagePickerController to Crop a Square Image

后端 未结 2 960
不思量自难忘°
不思量自难忘° 2021-02-19 04:28

How do we force UIIImagePickerController to crop a square image?

I have searched all over and I haven\'t found a solid solution. Thankyo

var imagePicker         


        
2条回答
  •  旧时难觅i
    2021-02-19 05:04

    You are doing it correctly up until you receive your delegate callback, within the callback you need to specify that it's the edited image that you want to use. Please note that i'm using a different delegate method here.

    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
        if let chosenImage = info[UIImagePickerControllerEditedImage] as? UIImage {
    
            profilePictureSelected = true;
    
            profilePictureImageView.image = chosenImage;
        }
        picker.dismissViewControllerAnimated(true, completion: nil);
    }
    

提交回复
热议问题