在我的应用程序中,我使用UIImagePickerControllerCropRect裁剪图像,但我想减小自动出现的iphone裁剪框的大小,以便我的图像裁剪到我想要的完美尺寸。我正在使用以下代码:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.allowsImageEditing = YES;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = image;
CGSize size = [imageView.image size];
CGRect cropRect = CGRectMake(0.0, 0.0, size.width, size.height);
NSLog(@"Original image size = (%f, %f)", size.width, size.height);
NSValue *cropRectValue = [editingInfo objectForKey:@"UIImagePickerControllerCropRect"];
cropRect = [cropRectValue CGRectValue];
UIImageWriteToSavedPhotosAlbum(imageView.image, self, nil, nil);
}