Set dimensions for UIImagePickerController “move and scale” cropbox

前端 未结 4 1693
忘掉有多难
忘掉有多难 2020-11-28 04:20

How does the \"move and scale screen\" determine dimensions for its cropbox?

Basically I would like to set a fixed width and height for the \"CropRect\" and let the

4条回答
  •  被撕碎了的回忆
    2020-11-28 05:00

    It's now later than late but may be useful for someone. This is the library I've used for swift (many thanks to Tim Oliver):

    TOCropViewController

    as described in README file in GitHub link above, by using this library you can get cropped images in user-defined rectangular and also in a circular mode, e.g. for updating profile image. below is sample code from GitHub:

    func presentCropViewController {
      let image: UIImage = ... //Load an image
    
      let cropViewController = CropViewController(image: image)
      cropViewController.delegate = self
      present(cropViewController, animated: true, completion: nil)
    }
    
    func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int) {
            // 'image' is the newly cropped version of the original image
        }
    

提交回复
热议问题