Yes, we can do it.
Create a user-defined function as follows:
- (UIImage *)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect { CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect); UIImage *cropped = [UIImage imageWithCGImage:imageRef]; CGImageRelease(imageRef); return cropped; }
And name this code:
UIImage *img1=[self imageByCropping:img toRect:CGRectMake(0,0, 106.6, 106.6)]; UIImageView *image_view=[[UIImageView alloc] initWithImage:img1];
Suresh.D
source share