gpt4 book ai didi

ios - UIImagePickerController - 将图片裁剪成正方形(纵向)

转载 作者:IT王子 更新时间:2023-10-29 08:19:19 26 4
gpt4 key购买 nike

我正在使用 UIImagePickerController 拍摄和编辑照片。它在风景中工作正常,但在肖像中它会将图片裁剪成正方形(不允许像在风景中那样缩小图像以完全适合方形裁剪区域。有什么想法吗?

代码:

-(IBAction)initCamera:(id)sender{

//Init imagePicker instance
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];

[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setShowsCameraControls:YES];
[imagePicker setAllowsEditing:YES];

[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}

最佳答案

查看 GKImagePicker库,它允许设置自定义图像裁剪区域,如下所示:

self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;

[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];

关于ios - UIImagePickerController - 将图片裁剪成正方形(纵向),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9362712/

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