背景
由于项目需求从手机相册中取出图片或者拍摄照片后对图片进行固定尺寸裁剪,而系统提供的UIImagePickerController只支持正方形剪切,所以我们需要自定制裁剪界面进行图片剪切实现所需求的功能。
效果图:
使用方法:
//单例工具
LDImagePicker *imagePicker = [LDImagePicker sharedInstance];
imagePicker.delegate = self;
//设置宽高比scale来设置剪切框大小,剪切框宽度固定为屏幕宽度
[imagePicker showImagePickerWithType:buttonIndex InViewController:self Scale:0.75];
//原生图片选择调用
//[imagePicker showOriginalImagePickerWithType:buttonIndex InViewController:self];
- (void)imagePickerDidCancel:(LDImagePicker *)imagePicker{
}
- (void)imagePicker:(LDImagePicker *)imagePicker didFinished:(UIImage *)editedImage{
self.imgeView.image = editedImage;
}
支持pod管理
pod 'LDImagePicker'
源码地址:https://github.com/LazyDuan/LDImagePicker
感觉好用的请挥动你的鼠标帮我点个star !