How do you crop an image in iOS

后端 未结 4 602
我在风中等你
我在风中等你 2020-12-13 19:05

I have a photo app where you can add stickers in one section. When you\'re finished I want to save the image. Here is the code that I have to do that.

if         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 19:33

    Refer the below link for crop image

    https://github.com/myang-git/iOS-Image-Crop-View

    ** How to Use **
    
    Very easy! It is created to be a drop-in component, so no static library, no extra dependencies. Just copy ImageCropView.h and ImageCropView.m to your project, and implement ImageCropViewControllerDelegate protocol.
    Use it like UIImagePicker:
    - (void)cropImage:(UIImage *)image{
        ImageCropViewController *controller = [[ImageCropViewController alloc] initWithImage:image];
        controller.delegate = self;
        [[self navigationController] pushViewController:controller animated:YES];
    }
    - (void)ImageCropViewController:(ImageCropViewController *)controller didFinishCroppingImage:(UIImage *)croppedImage{
       image = croppedImage;
       imageView.image = croppedImage;
       [[self navigationController] popViewControllerAnimated:YES];
    }
    - (void)ImageCropViewControllerDidCancel:(ImageCropViewController *)controller{
        imageView.image = image;
        [[self navigationController] popViewControllerAnimated:YES];
    }
    

提交回复
热议问题