// 1 CGRectInset
If you need to create a rectangle that is either larger or smaller than an existing rectangle, centered on the same point, try CGRectInset:
123456789101112131415 | CGRect rect5 = CGRectMake(100, 100, 100, 100);// Use positive values for a smaller rectangleCGRect rect6 = CGRectInset(rect, 25, 25); NSLog(@"%rect5: %@", NSStringFromCGRect(rect5));NSLog(@"%rect6: %@", NSStringFromCGRect(rect6)); ... CGRect rect7 = CGRectMake(100, 100, 100, 100);// Use negative values for a larger rectangleCGRect rect8 = CGRectInset(rect, -25, -25); NSLog(@"rect7: %@", NSStringFromCGRect(rect7));NSLog(@"rect8: %@", NSStringFromCGRect(rect8)); |