是否可以为 UIImagePickerController 的编辑器设置尺寸?

Is it possible to set dimensions for UIImagePickerController's editor?

提问人:MePengusta 提问时间:7/25/2018 更新时间:7/25/2018 访问量:65

问:

我正在尝试让用户从他们的图库中选择一张照片并将这张照片裁剪为特定尺寸,例如圆形 , 80 x 60 尺寸的照片。

@IBOutlet var imageView: UIImageView!

@IBAction func choosePhoto(_ sender: Any) {

    let imagePickerController = UIImagePickerController()

    imagePickerController.delegate = self
    imagePickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary
    imagePickerController.allowsEditing = true
    self.present(imagePickerController, animated: true, completion: nil)
}

 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    let choosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
    imageView.image = choosenImage
    dismiss(animated: true, completion: nil)
}

我使用此代码选择照片,但编辑屏幕是一个矩形,所以这不是我要找的。是否可以更改编辑屏幕的尺寸?

iOS iPhone Swift UIImagePickerController

评论


答:

0赞 Anuraj 7/25/2018 #1

默认情况下,iOS 没有任何圆形裁剪功能。您将需要集成外部库来实现裁剪功能。

您可以将这些用于循环裁剪 https://github.com/kekearif/KACircleCropViewController https://github.com/TimOliver/TOCropViewController