TimOliver / TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects
http://www.timoliver.com.au/2015/06/21/tocropviewcontroller-an-open-source-image-cropper-for-ios/
MIT License
4.7k stars 938 forks source link

Accesing cropView #358

Open Calugarul opened 5 years ago

Calugarul commented 5 years ago

Hi, is there a way to use TOCropViewController to add some image effects? Basically, I need to be able to access the image that will be set as cropped.

I already managed to place the navigation bar, add a button and made a collectionView with the Image effects. Upon selection, it will send back to previewController that will make a new TOCropView and the image will be shown with the effect but when it saves is still the original image and without crop. I understand I am not modifying the main cropView, it still exists and that is the one being sent. Is there a way to achieve this? This is my code:


func comingBackFromEffects() {
        var cropView = TOCropView()
        cropView.contentMode = .scaleAspectFit
        cropView = TOCropView(image: PassDataToChat.ImageToSend.image!)
        cropView.imageCropFrame = self.cropView.imageCropFrame
        cropView.frame = self.cropView.frame
        cropView.resetLayoutToDefault(animated: false)

        //self.cropView.removeFromSuperview()
        self.view.addSubview(cropView)
        self.view.layoutIfNeeded()
    }
TimOliver commented 5 years ago

Hi @MarianPetrisor! Sorry for the late reply!

Hmm, this is an interesting use-case! I never really designed the controller with the ability to hot-swap images in and out.

One thing you might be able to do is capture the CGRect output from the crop controller and manually do your own cropping operation on the image with the effects applied.

Without modifying the code, there's not too much else you can do, sorry!