To crop image in iOS use the following method.
it will crop the image from the visible frame of the imageView.
-(UIImage *)imageFromImageView:(UIImageView *)imageView rectFrame:(CGRect)frame{
UIGraphicsBeginImageContextWithOptions(frame.size, imageView.opaque, 2.0);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextConcatCTM(c, CGAffineTransformMakeTranslation(-frame.origin.x, -frame.origin.y));
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
0 Comment(s)