Reputation: 3927
My application have an function that allow user to move and scale the image just like setting allowsEditing = YES with UIImagePickerController.
My approach is having a scrollview which allow user to zoom with level 1-4 There is only a image view on the scrollview.
At the end, I want to crop the image as the screen size. How can I do it?
Upvotes: 1
Views: 1182
Reputation: 22334
The trick is to capture the layer of the view containing the scaled / rotated image. In this case you need to capture the scrollview layer NOT the image itself.
I have a UIImage capture category for this...check out my article and download the source code.
UPDATE: to crop part of the image as per the comment below...
First capture the whole view then crop the image to the specified rect using the following method in the UIImage+Resize
category (also in the article...)
- (UIImage *)croppedImage:(CGRect)bounds;
Upvotes: 2