RSKImageCropViewController与TZIma
1、TZImagePickerController
TZImagePickerController是一个封装好的选择相册图片的三方库,支持多选,仿微信的选择图片。可用cocoapods直接导入
使用方法:
1、#import "TZImagePickerController.h"
2、<TZImagePickerControllerDelegate>
3、TZImagePickerController *imagePC=[[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];//设置多选最多支持的最大数量,设置代理
[imagePC setDidFinishPickingPhotosHandle:^(NSArray*imageArray, NSArray *array) {
//点击确定后回道主界面
}];
[self presentViewController:imagePC animated:YES completion:nil];//跳转
2、RSKImageCropViewController
RSKImageCropViewController是一个用来对相片进行裁剪的三方库。可用cocoapods直接导入。
1、#import "RSKImageCropper.h"
2、<RSKImageCropViewControllerDelegate>
3、RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:image cropMode:RSKImageCropModeCustom];//传入图片与裁剪框的类型
//RSKImageCropModeCustom-自定义
//RSKImageCropModeCircle-圆形
//RSKImageCropModeSquare-矩形
imageCropVC.delegate = self;
imageCropVC.dataSource=self;
[self.navigationController pushViewController:imageCropVC animated:YES];
如果cropMode为RSKImageCropModeCustom自定义类型,则需要加入RSKImageCropViewControllerDataSource进行自定义裁剪框
- (CGRect)imageCropViewControllerCustomMaskRect:(RSKImageCropViewController *)controller
{
//返回图片的位置
return CGRectMake(0, (SCREEN_HEIGHT-100)/2, SCREEN_WIDTH, 100);
}
- (UIBezierPath *)imageCropViewControllerCustomMaskPath:(RSKImageCropViewController *)controller
{
//返回裁剪框的位置
UIBezierPath *path=[UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, (SCREEN_HEIGHT-100)/2, SCREEN_WIDTH, 100) cornerRadius:0];
return path;
}
3、TZImagePickerController与RSKImageCropViewController混合使用
首先设置TZImagePickerController最大选择数为1,然后在setDidFinishPickingPhotosHandle的回调中把image传给RSKImageCropViewController即可。
TZImagePickerController *imagePC=[[TZImagePickerController alloc]initWithMaxImagesCount:3 delegate:self]; [imagePC setDidFinishPickingPhotosHandle:^(NSArray*imageArray, NSArray *array) {
RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:imageArray[0] cropMode:RSKImageCropModeCustom];
imageCropVC.delegate = self;
imageCropVC.dataSource=self;
[self.navigationController pushViewController:imageCropVC animated:YES];
}];
[self presentViewController:imagePC animated:YES completion:nil];