标签:
UIView *v1=[[UIView alloc] initWithFrame:CGRectMake(10, 100, 200, 100)];
v1.backgroundColor=[UIColor redColor];
[self.view addSubview:v1];
UIView *v2=[[UIView alloc] initWithFrame:CGRectMake(50, 150, 200, 100)];
v2.backgroundColor=[UIColor yellowColor];
[self.view addSubview:v2];
UIView *v3=[[UIView alloc] initWithFrame:CGRectMake(100, 200, 200, 100)];
v3.backgroundColor=[UIColor blueColor];
[self.view addSubview:v3];
// [self.view insertSubview:v2 atIndex:0];
// [self.view insertSubview:v1 aboveSubview:v3];
// [self.view insertSubview:v2 belowSubview:v1];
// [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:2];
//将一个view放到最下面
[self.view sendSubviewToBack:v1];
//将一个view放到最上面
[self.view bringSubviewToFront:v1];
标签:
原文地址:http://www.cnblogs.com/wwm881101/p/5462612.html