视图关系及遍历查找视图
来源:互联网 发布:怎样办理淘宝3c认证 编辑:程序博客网 时间:2024/06/07 10:13
// 会将响应者链上的所有子视图统统移除-------------------- [tv1 removeFromSuperview];// 循环创建10个子视图 v1加在v2上 v2加在v3上 .... 随机颜色 子视图比父视图宽高各小20个像素-------------------------------------------------------- UIView * preView = nil; for (int i = 0; i < 10; i++) { UIView * v = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 320-20*i, 260-20*i)]; // 生成随机色 int r = arc4random() % 256; int g = arc4random() % 256; int b = arc4random() % 256; v.backgroundColor = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]; // 第一个视图 if (preView == nil) { v.frame = CGRectMake(0, 220, 320, 260); [self.window addSubview:v]; }else{ [preView addSubview:v]; } // 保存上一级父视图对象 preView = v; } UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 200, 30)]; label.text = @"Test"; [self.window addSubview:label]; NSLog(@">>>%@",self.window.subviews);// 遍历查找子视图 查找一种类型的视图 UIButton UILabel...---------------------------------------- for (UIView * v in self.window.subviews) { // v对象的类型是 UILabel if ([v isKindOfClass:[UILabel class]]) { UILabel * l = (UILabel *)v; l.textColor = [UIColor redColor]; } }
0 0
- 视图关系及遍历查找视图
- 查找视图
- 遍历子视图
- Map集合视图遍历
- 根据Tag查找视图
- cocoa查找子视图
- 查找hive中的视图
- iOS 查找子视图
- 查找hive中的视图
- 表和视图关系
- IIService类关系视图
- android视图继承关系
- android视图继承关系
- oracle数据库----关系视图
- java关系视图
- 遍历子视图的子视图
- Web MVC框架-视图模板查找及组织
- Web MVC框架-视图模板查找及组织
- 已知直线上两点求直线的一般式方程
- pat1038 Recover the Smallest Number
- Could not load the Tomcat server configuration at /usr/apache-tomcat-7.0.42/conf. The configuration
- MVC框架总结
- bashrc 和 profile
- 视图关系及遍历查找视图
- Java中数组的存储与内存分配
- poj 3233 Matrix Power Series (构造矩阵)
- Linux下设计一个简单的线程池
- iOS Crash 文件 分析出出错对应代码
- git修改文件权限引发冲突
- cvc-complex-type.3.2.2: Attribute 'content-negotiation-manager' is not allow
- javascript 闭包详解
- chrome 滚动条