我刚刚找到了一种方法来更改裁剪框的矩形,该裁剪框在捕获图像后出现UIImagePickerViewController
。这可以在以下帮助下完成UIImagePickerControllerCropRect
。但我不知道如何使用它。最初的裁剪框是正方形的。我希望它是矩形的。
有人可以与我分享一个例子吗?
是的,我们可以做到。
像这样创建用户定义函数:
- (UIImage *)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect
{
CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect);
UIImage *cropped = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return cropped;
}
并调用这段代码:
UIImage *img1=[self imageByCropping:img toRect:CGRectMake(0,0, 106.6, 106.6)];
UIImageView *image_view=[[UIImageView alloc] initWithImage:img1];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)