问题
近期在实际开发工作中遇到产品需求,要对用户上传的图片(身份证)进行旋转、捏合、放大缩小进行裁剪,而调用系统的裁剪无法满足
picker.allowsEditing = YES;
由于系统裁剪是正方形图片,而身份证的长宽比约为 1.6:1
解决办法
自定义控制器对拍摄照片或相册选择的照片进行自由裁剪
直接上方法源码,可直接复制调用哦~~~
- (void)showImagePicker:(UIImagePickerControllerSourceType)sourcetype {
ONImagePickerController *imagePicker = [ONImagePickerController sharedInstance];
[imagePicker showImagePickerWithPresentController:self sourceType:sourcetype allowEdit:YES cutFrame:CGRectMake(0, (kScreenHeight - kScreenWidth/1.6)/2, kScreenWidth, kScreenWidth/1.6)];
[imagePicker setChooseImageBlock:^(UIImage * _Nonnull image) {
NSLog(@"--image--%@",image);
self.imageView.image = image;
}];
}
效果图
ONTailoringPictur
话不多说,直接上Demo 【链接】https://github.com/MrJalen/ONTailoringPicture