I need to change the size of the cropping rect when using UIImagePickerController
. In my case, I need the user to select images that are 320x385 but the crop rect currently only allows 320x320 (when allow editing is on).
Any ideas?
I have done a similar project. You have to use an image controller. Above your image controller you have to add another image controller (just because this is your crop area) aboveImageController's unfilled/empty part is where you will take. (so you should have an image with 320x480 sized and 320x385 empty in it.)
UIImage *image=theimageView.image;
CGSize newSize;
newSize.width=320;
newSize.height=385;
UIGraphicsBeginImageContext(newSize);
//x=0 (because widhth : 320) y=0 (aboveImageController's empty part's start)
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGImageRef imageRef = CGImageCreateWithImageInRect([newImage CGImage], rect);
UIImage *img = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With