gpt4 book ai didi

iphone - 如何使用 UIImagePickerControllerCropRect

转载 作者:可可西里 更新时间:2023-11-01 03:09:10 25 4
gpt4 key购买 nike

我刚刚想出了一种方法来更改从 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];

关于iphone - 如何使用 UIImagePickerControllerCropRect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10100220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com