Question

I've cropped my image using the code below.

- (UIImage *)crop:(CGRect)rect image:(UIImage *)image {
  if (image.scale > 1.0f) {
    rect = CGRectMake(rect.origin.x * image.scale,
                      rect.origin.y * image.scale,
                      rect.size.width * image.scale,
                      rect.size.height * image.scale);
  }

  CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
  UIImage *result = [UIImage imageWithCGImage:imageRef scale:image.scale orientation:image.imageOrientation];
  CGImageRelease(imageRef);
  return result;
}

- (void)function
{
  CGRect nf = CGRectMake(0, 0, 325, 303); //The area I need to crop

  imageView.image = [self crop:nf image:imageView.image];
  // Here I need to resize the new image
}

Now, I need to resize this picture that I cropped. I tried :

  • Changing the frame -> no effect
  • Scaling image with 'CGAffineTransformMakeScale' -> no effect

I need your help please.

EDIT : I tried to change frame like this :

imageView.frame = CGRectMake(x, y, width, height);

Was it helpful?

Solution 2

I guess I wasn't using CGAffineTransformMakeScale correctly because I finally reach it writing

imageView.transform = CGAffineTransformMakeScale(0.x, 0.x);

OTHER TIPS

Try this

 [image drawInRect:CGRectMake(0, 0,width,height)];

Post some code of What you've tried

Refer this Answer The simplest way to resize an UIImage?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top