本文介绍了UIImagePickerController - 裁剪图片到正方形(在纵向)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用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];
}检查库,它可以设置您的自定义图像裁剪区域,如下所示: self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320,90);
self.imagePicker.delegate = self;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];
I'm using the UIImagePickerController to take and edit a picture. it works fine in landscape, but in portrait it will crop the picture into a square (does not allow to reduce the image to fit fully into the square crop field like in landscape. Any ideas?
code:
-(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];
}
解决方案 Check out GKImagePicker library, it allows to set your custom image crop area, like this:
self.imagePicker = [[GKImagePicker alloc] init];
self.imagePicker.cropSize = CGSizeMake(320, 90);
self.imagePicker.delegate = self;
[self presentModalViewController:self.imagePicker.imagePickerController animated:YES];
这篇关于UIImagePickerController - 裁剪图片到正方形(在纵向)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!