CGRectInset(CGRect rect,CGFloat dx,CGFloat dy) 以rect为中心按dx,dy缩小(dx,dy正)或放大(dx,dy -)
CGRectOffset(CGRect rect,CGFloat dx,CGFloat dy) 以rect左上角为中心按dx,dy沿方向移动
UIView * view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 80)];
view1.backgroundColor = [UIColor redColor];
[self.view addSubview:view1];
UIView * view2 = [UIView new];
view2.frame = CGRectInset(view1.frame, 20, 20);
view2.backgroundColor = [UIColor blackColor];
[self.view addSubview:view2];
Paste_Image.png
Paste_Image.png
网友评论