how to change the UIImagePickerController crop frame

后端 未结 3 677
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 20:01

when opening working with an UIImagePickerController and setting allowsImageEditing = YES; there is a default cropping frame that is 320x320. In my case, I would like to se

3条回答
  •  没有蜡笔的小新
    2020-12-08 20:56

    You can try ShittyImageCrop. It's good for cropping to a specific aspect ratio. In your case, present it with aspect ratio 4:3 (or 3:4 in landscape) like this:

    let cropVC = ShittyImageCropVC(frame: (self.navigationController?.view.frame)!, image: imageToCrop, aspectWidth: 4, aspectHeight: 3)
    self.navigationController?.present(cropVC, animated: true, completion: nil)
    

    After that you can use some other code to just scale it to desired resolution (320x240 or 240x320).

提交回复
热议问题