视图层级管理
2014-05-20 14:10
155 查看
1.一个视图作为父视图时,可以添加多个子视图2.一个视图作为子视图时,只有一个父视图3.新添加(后添加)的子视图,永远在其他同级的子视图的前边(上边)4.父视图使用数组管理子视图subViews5.视图使用树形结构,管理所有子视图6.父视图可以修改已经存在的所有子视图的关系:提前 置后 交换 子视图可以从父视图上移除.以上操作均会影响subviews7.父视图可以直接添加子视图.插入子视图:根据索引,显示在指定子视图上方,或者显示在指定子视图的下边8.viewWithTag:通过tag值搜索本视图及所有子视图,tag值某认为0;
//创建蓝色视图,添加window UIView * blueView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)]; blueView.backgroundColor = [UIColor blueColor]; blueView.tag = 100; [self.window addSubview:blueView]; [blueView release]; //创建蓝色的子视图,红的 UIView * redView = [[UIView alloc] initWithFrame:CGRectMake(70, 70, 50, 50)]; redView.backgroundColor = [UIColor redColor]; [blueView addSubview:redView]; [redView release]; //创建黄色视图,添加到window UIView * yellowView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)]; yellowView.backgroundColor = [UIColor yellowColor]; [self.window addSubview:yellowView]; [yellowView release]; //将蓝色视图放在前头 // [self.window bringSubviewToFront:blueView]; //将蓝色视图放在最后头 //[self.window sendSubviewToBack:blueView]; //将蓝色和黄色位置交换 //[self.window exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; //将蓝色视图删除 //[blueView removeFromSuperview]; //将蓝色视图放在1的后头 //[self.window insertSubview:blueView atIndex:1]; //将蓝色放在黄色前头 [self.window insertSubview:blueView aboveSubview:yellowView]; //插入蓝色在黄色的前头 //[self.window insertSubview:blueView belowSubview:yellowView]; //isDescendantOfView:(UIView *)view方法,判断view是不是指定视图的子视图 [redView isDescendantOfView:blueView]; NSLog(@"subviews = %@",self.window.subviews); UIView * blackView = [[UIView alloc] initWithFrame:CGRectMake(40, 200, 200, 200)]; blackView.backgroundColor = [UIColor blackColor]; [self.window addSubview:blackView]; [self.window insertSubview:blackView belowSubview:yellowView]; [self.window insertSubview:yellowView aboveSubview:blueView]; [self.window insertSubview:blackView atIndex:1]; //隐藏蓝色视图 //blueView.hidden = YES; //修改蓝色视图的透明度,父视图的alpha会影响子视图. blueView.alpha = 0.5; yellowView.alpha = 0.5; blackView.alpha = 0.5;
相关文章推荐
- UI初级--视图层级管理
- SQL 数据库,表, 视图管理语句
- CMS:文章管理之视图(2)
- 《03. oracle 对象管理--视图》
- 大数据量的管理:分区视图
- CMS:文章管理之视图(6)
- 【视频】配置信息管理 的 使用方法(三):查看和修改元数据、查看数据库的表视图存储过程等信息
- 源码-Oracle数据库管理-第七章-视图-Part 2
- 链路发现及拓扑管理(全局网络视图拓扑的学习机制)
- 开发笔记 视图管理 子视图切图和查询子视图
- 用GDB命令PO(print-object)打印UIView的视图层级
- 动态管理视图DMV和函数DMF
- New UI-<merge>标签减少视图层级,让布局更高效
- Web 页面浏览客户端资源管理视图
- SQL Server 动态管理视图(DMVs)
- CMS:文章管理之视图(2)
- sql之视图管理
- 动态管理视图
- 如何进行SQL性能优化?-使用动态管理视图和函数
- 【视频】配置信息管理 的 使用方法(三):查看和修改元数据、查看数据库的表视图存储过程等信息