Add a circular cropping component for UIImagePicker?(为 UIImagePicker 添加圆形裁剪组件?)
问题描述
我有一个圆形框架 UIImageView
,我需要在从照片库中选择图像后,为 UIImagePickerController
添加一个圆形框架裁剪工具.非常类似于 Instagram 的 UIImagePicker 的
裁剪组件.如何添加这种类型的组件?
更新
我发现这个 repo 带有一个圆形裁剪工具
我的裁剪视图中的按钮被禁用,这意味着我无法选择它们.调试器向我传递什么消息?
这是我的代码:
@IBAction func chooseProfilePicture(sender: AnyObject) {var myPickerController = UIImagePickerController()myPickerController = UIImagePickerController()myPickerController.delegate = self;myPickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibraryself.presentViewController(myPickerController,动画:真,完成:无)}func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject: AnyObject]) {var image : UIImage = (info[UIImagePickerControllerOriginalImage] as?UIImage)!editProfilePictureImageView.image = 图像self.dismissViewControllerAnimated(false, completion: { () -> Void invar imageCropVC : RSKImageCropViewController!imageCropVC = RSKImageCropViewController(图像:图像,cropMode:RSKImageCropMode.Circle)imageCropVC.delegate = selfself.navigationController?.pushViewController(imageCropVC, 动画: true)})}
I Have a circular framed UIImageView
and I need to add a circular framed cropping tool for the UIImagePickerController
, after the image is selected from a photo library. Very similar to Instagram's UIImagePicker's
crop component. How do I add this type of component?
UPDATE
I've found this repo with a circular cropping tool https://github.com/ruslanskorb/RSKImageCropper
but can someone guide me on to how to implement this cropping tool with the UIImagePickerController after the user selects a photo from the photo library?
UPDATE
I am getting the following message in my debugger :
and the buttons in my crop view are disabled, meaning I cannot select them.. what message is the debugger relaying on to me?
here is my code:
@IBAction func chooseProfilePicture(sender: AnyObject) {
var myPickerController = UIImagePickerController()
myPickerController = UIImagePickerController()
myPickerController.delegate = self;
myPickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
self.presentViewController(myPickerController, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
var image : UIImage = (info[UIImagePickerControllerOriginalImage] as? UIImage)!
editProfilePictureImageView.image = image
self.dismissViewControllerAnimated(false, completion: { () -> Void in
var imageCropVC : RSKImageCropViewController!
imageCropVC = RSKImageCropViewController(image: image, cropMode: RSKImageCropMode.Circle)
imageCropVC.delegate = self
self.navigationController?.pushViewController(imageCropVC, animated: true)
})
}
Example Demo
Yes you can add RSKImageCropper
in your UIImagePickerController
define imagePicker
var imagePicker : UIImagePickerController!
in ViewDidLoad
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary;
self.presentViewController(imagePicker, animated: true, completion: nil)
Delegate methode :
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject])
{
var image : UIImage = (info[UIImagePickerControllerOriginalImage] as? UIImage)!
picker.dismissViewControllerAnimated(false, completion: { () -> Void in
var imageCropVC : RSKImageCropViewController!
imageCropVC = RSKImageCropViewController(image: image, cropMode: RSKImageCropMode.Circle)
imageCropVC.delegate =self
self.navigationController?.pushViewController(imageCropVC, animated: true)
})
}
see :
这篇关于为 UIImagePicker 添加圆形裁剪组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为 UIImagePicker 添加圆形裁剪组件?
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01