iOS CGRectInset
11 Jun 2015dx, dy为正
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 500, 500)];
redView.backgroundColor = [UIColor redColor];
[self.view addSubview:redView];
UIView *blueView = [[UIView alloc]init];
blueView.frame = CGRectInset(redView.frame, 50, 50);
blueView.backgroundColor = [UIColor blueColor];
[self.view addSubview:blueView];
dx, dy为负
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 500, 500)];
redView.backgroundColor = [UIColor redColor];
[self.view addSubview:redView];
UIView *blueView = [[UIView alloc]init];
blueView.frame = CGRectInset(redView.frame, -50, -50);
blueView.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:0.5];
[self.view addSubview:blueView];
注意blueView加了50%的透明,否则redView被完全覆盖