CGRectInset
定义:
CG_EXTERN CGRect CGRectInset(CGRect rect, CGFloat dx, CGFloat dy);//作用是以当前矩形为中心,放大缩小宽高,获取新的矩形
UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
view1.backgroundColor = [UIColor redColor];
[self.view addSubview:view1];
UIView *view2 = [[UIView alloc]initWithFrame:CGRectInset(view1.frame, 20, 20)];//以view1为中心缩小20px
view2.backgroundColor = [UIColor yellowColor];
[self.view addSubview:view2];
###### CGRectOffset 定义: ```c CG_EXTERN CGRect CGRectOffset(CGRect rect, CGFloat dx, CGFloat dy);///作用是以当前矩形为基础,水平、上下移动后产生新的矩形 ```
UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
view1.backgroundColor = [UIColor redColor];
[self.view addSubview:view1];
UIView *view2 = [[UIView alloc]initWithFrame:CGRectOffset(view1.frame, 20, 20)];
view2.backgroundColor = [UIColor yellowColor];
[self.view addSubview:view2];