标签:
//背景颜色
self.window.backgroundColor = [UIColor whiteColor];
//让window能够显示出来
//透明度
self.window.alpha=1.0;
/*
//所有的控件都继承与UIView
//第一步:对视图开辟空间,并初始化
UIView *view1=[[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
//第二部:对视图进行设置
view1.backgroundColor=[UIColor blueColor];
//第三部:添加到window上
[self.window addSubview:view1];
//指定的index插入子视图
UIView *view4=[[UIView alloc] initWithFrame:CGRectMake( 0, 0 ,100 ,100 )];
view4.backgroundColor=[UIColor orangeColor];
[self.window insertSubview:view4 atIndex:0];
[view4 release];
//在指定的视图上面添加子视图
UIView *view5=[[UIView alloc]initWithFrame:CGRectMake(50,50 ,200 ,200 )];
view5.backgroundColor=[UIColor cyanColor];
[self.window insertSubview:view5 aboveSubview:view1];
[view5 release];
//删除指定视图
[view5 removeFromSuperview];
//交换两个视图
[self.window exchangeSubviewAtIndex:1 withSubviewAtIndex:2];
*/
//把视图移到最前面(交换的是视图层次,不是位置)
[self.window bringSubviewToFront:cview];
//指定视图移到最后面
[self.window sendSubviewToBack:bview];
//取父视图下面所有的子视图subviews 数组形式返回
NSArray *subviewArray = self.window.subviews;
NSLog(@"%d",subviewArray.count);
//强制转换,可以改变子视图颜色
((UIView *)subviewArray[0]).backgroundColor=[UIColor yellowColor];
标签:
原文地址:http://www.cnblogs.com/-ios/p/4672567.html