如何将圆形裁剪功能添加到此 UIImagePickerController,目前它显示为正方形
Posted
技术标签:
【中文标题】如何将圆形裁剪功能添加到此 UIImagePickerController,目前它显示为正方形【英文标题】:How to add the circular crop feature to this UIImagePickerController, currently it comes up as a square 【发布时间】:2018-05-24 16:48:52 【问题描述】:如何给这个 UIImagePickerController 添加圆形裁剪功能,目前它是一个正方形。我在其他一些帖子中说您必须安装一些 podfile,但是有什么简单的方法可以在此处添加该裁剪视图吗?
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
var selectedImageFromPicker: UIImage?
if let editedImage = info["UIImagePickerControllerEditedImage"] as? UIImage
selectedImageFromPicker = editedImage
else if let originalImage = info["UIImagePickerControllerOriginalImage"] as? UIImage
selectedImageFromPicker = originalImage
【问题讨论】:
【参考方案1】:有什么简单的方法可以在这里添加裁剪视图吗?
不作为图像选择器控制器的一部分,不。实际上,要实现您所描述的,您将必须编写自己的“圆形裁剪”界面(一种或另一种方式),然后不使这个图像选择器控制器可编辑;相反,让用户选择一张图片,然后将其交给你的圆形裁剪界面让用户裁剪它。
【讨论】:
extension LoginController: UIImagePickerControllerDelegate, UINavigationControllerDelegate @objc func handleSelectProfileImageView() let picker = UIImagePickerController() picker.delegate = self picker.allowsEditing = true present(picker, Animation: true, completion: nil) 有没有办法添加...让shittyVC = ShittyImageCropVC(frame: (self.navigationController?.view.frame)!, image: UIImage(named:"img")!, aspectWidth: 4、aspectHeight: 3) self.navigationController?.present(shittyVC, animated: true, completion: nil)以上是关于如何将圆形裁剪功能添加到此 UIImagePickerController,目前它显示为正方形的主要内容,如果未能解决你的问题,请参考以下文章