Hi all!
I would like to know if it's possibe to show the circular crop area to users but instead of getting the image cropped with a circle, just get it cropped with the min rectangle containing that circle, does that make sense?
Thanks!
Hi @agusguerra10!
If you just want the CGRect
value from an image, even in circular mode, you just need to implement the - (void)cropViewController:(TOCropViewController *)cropViewController didCropImageToRect:(CGRect)cropRect angle:(NSInteger)angle
delegate method. :)
You can also implement - (void)cropViewController:(TOCropViewController *)cropViewController didCropToImage:(UIImage *)image withRect:(CGRect)cropRect angle:(NSInteger)angle
if you want a square copy of that image.
Hope that helped! Let me know if you were looking for something else!
Dooh! Didn't know that the:
- (void)cropViewController:(TOCropViewController *)cropViewController didCropToImage:(UIImage *)image withRect:(CGRect)cropRect angle:(NSInteger)angle
delegate was called even if I set the the crop area to circular :)
Thanks a lot Tim! Cheers!
Agus.
really?
i am looking for the answer to this question.
i have set the style circular.
but not call the delegate function
func cropViewController(_ cropViewController: TOCropViewController, didCropToImage image: UIImage, rect cropRect: CGRect, angle: Int)
i have solved the problem
this delegate method will be called even if set the crop area to circular.
in the delegate i use the - (nonnull UIImage *)croppedImageWithFrame:(CGRect)frame angle:(NSInteger)angle circularClip:(BOOL)circular;
to crop it to get the rect image. but need set circularClip to false.
i want to ask Tim,it is right?
what agusguerra10 said is not called in my project. xcode9 swift4.
No worries @agusguerra10! Yeah, in retrospect, it wasn't a great pattern basing logic on which delegate methods the delegate implemented; it's caused a little bit of confusion. 😅
@agusguerra10 I just checked the code for handling delegate callbacks. That's correct. If you implement any of the circular delegate methods in circular mode, then the one that returns a square image is ignored.
If you think this should be changed, it might be better to track it in a new issue. Thanks! :)
Most helpful comment
Dooh! Didn't know that the:
- (void)cropViewController:(TOCropViewController *)cropViewController didCropToImage:(UIImage *)image withRect:(CGRect)cropRect angle:(NSInteger)angle
delegate was called even if I set the the crop area to circular :)
Thanks a lot Tim! Cheers!
Agus.