我正试图让用户从自己的照片库中选择一张照片,并将其裁剪为特定尺寸,例如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)
}
我使用此代码选择照片,但是编辑屏幕是一个矩形,所以它不是我想要的。是否可以更改编辑屏幕的尺寸?
答案 0 :(得分:0)
默认情况下,iOS没有任何循环裁剪功能。您将需要集成外部库以实现裁剪功能。
您可以将其用于循环裁剪https://github.com/kekearif/KACircleCropViewController https://github.com/TimOliver/TOCropViewController