ios - Add a circular cropping component for UIImagePicker? -
i have circular framed uiimageview
, need add circular framed cropping tool uiimagepickercontroller
, after image selected photo library. similar instagram's uiimagepicker's
crop component. how add type of component?
update
i've found repo circular cropping tool https://github.com/ruslanskorb/rskimagecropper
but can guide me on how implement cropping tool uiimagepickercontroller after user selects photo photo library?
update
i getting following message in debugger :
and buttons in crop view disabled, meaning cannot select them.. message debugger relaying on me?
here 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) }) }
yes can add rskimagecropper
in 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 :
Comments
Post a Comment