RSKImageCropper
https://github.com/ruslanskorb/RSKImageCropper
An image cropper for iOS like in the Contacts app with support for landscape orientation.
一个iOS图片裁剪器,支持横竖屏切换.
Installation - 安装
CocoaPods is the recommended method of installing RSKImageCropper. Simply add the following line to your Podfile
:
Podfile
pod 'RSKImageCropper'
Basic Usage - 基本用法
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]; }
Delegate - 代理
RSKImageCropViewControllerDelegate
provides two delegate methods. To use them, implement the delegate in your view controller.
RSKImageCropViewControllerDelegate提供了两个代理方法.你需要在你的控制器中实现代理方法.
@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]; }
Coming Soon - 将要实现的功能
- Add more cropping guides. 支持更多的裁剪类型
- If you would like to request a new feature, feel free to raise as an issue. 如果你有着奇葩的想法,你可以提出来哦,亲^_^!
Demo - 应用示例
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.
编译以及运行RSKImageCropperExample工程,并做交互操作即可.