Creating our own crop rect in camera overlay

谁说我不能喝 提交于 2019-12-18 13:36:33

问题


I want to state my basic requirement which is to change the frame for crop rect in UIImagePickerController for a camera.

I just realized that it is not possible to change frame for crop rect. That leaves me with only one option i.e to create my own camera overlay wherein I can set frame for crop rect. I searched a lot but found nothing. I asked previously but didn't get anything. I don't even know is it possible and if yes then how to create it and move the crop box, scale it in accordance to default UIImagePickerController crop rect.


回答1:


You have to Implement your own CropRect. First set the

[picker setAllowsEditing:NO];

Then in didFinishPickingMediaWithInfo delegate Push your own CropRect View

CustomImageEditor *custom = [[CustomImageEditor alloc] initWithNibName:@"CustomImageEditor" bundle:nil];
[picker pushViewController:custom animated:YES];
[custom release];

while Pushing view pass the image to the Custom View like this

 UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
 custom.pickedImage = image;

In that customView you crop the image.

For croping the image try like this..

CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], cropRect);
UIImage *image = [UIImage imageWithCGImage:imageRef];


来源:https://stackoverflow.com/questions/10118955/creating-our-own-crop-rect-in-camera-overlay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!