用户可以更改在编辑屏幕中显示默认的裁剪框大小。我尝试使用以下代码:
- (UIImage *)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect {
CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect);
UIImage *cropped = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return cropped;
}
但它裁剪了固定区域。如何裁剪用户选择的区域?