An image cropper for iOS like in the Contacts app with support for landscape orientation.
CocoaPods is the recommended method of installing RSKImageCropper. Simply add the following line to your Podfile
:
pod 'RSKImageCropper'
Import the class header.
#import "RSKImageCropViewController.h"
Just create a view controller for image cropping and set the delegate.
- (IBAction)onButtonTouch:(UIButton *)sender
{
UIImage *image = [UIImage imageNamed:@"image"];
RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:image];
imageCropVC.delegate = self;
[self.navigationController pushViewController:imageCropVC animated:YES];
}
RSKImageCropViewControllerDelegate
provides two delegate methods. To use them, implement the delegate in your view controller.
@interface ViewController () <RSKImageCropViewControllerDelegate>
Then implement the delegate functions.
// Crop image has been canceled.
- (void)imageCropViewControllerDidCancelCrop:(RSKImageCropViewController *)controller
{
[self.navigationController popViewControllerAnimated:YES];
}
// The original image has been cropped.
- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage
{
self.imageView.image = croppedImage;
[self.navigationController popViewControllerAnimated:YES];
}
- Add more cropping guides.
- If you would like to request a new feature, feel free to raise as an issue.
Build and run the RSKImageCropperExample
project in Xcode to see RSKImageCropper
in action.
Have fun. Fork and send pull requests. Figure out hooks for customization.
Ruslan Skorb
This project is is available under the MIT license. See the LICENSE file for more info. Attribution by linking to the project page is appreciated.