Question

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

Was it helpful?

Solution

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.

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