3

I am using a CGRect to cut an image out of an imageview. The rectangle is generated automatically depending on features on the imageview but I would like to enlarge it slightly maybe by 10% but around the same point.

To get the sizes of something I would normally use frame like this:

CGRect frame = _imageView.frame;


    CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], frame);
    UIImage *img = [UIImage imageWithCGImage:imageRef];

Then change with origin.x however I am unable to get the frame of my existing rectangle.

Any help greatly appreciated on expanding a CGRect

EHarpham
  • 602
  • 1
  • 17
  • 34

1 Answers1

11

Have a look at CGRectInset, I think that will do what you want. Depending on the sign of the insets, you can make a rectangle that's smaller or larger than the original with the same center point.

rdelmar
  • 103,982
  • 12
  • 207
  • 218