子视图是以栈的方式存放的。每次addsubview时都是在最后面添加。每次在addsubview前和addsubview后可以看看[self.view.subViews count];你看看你的子视图是被添加到哪个位置了。另外[self.view addSubView:xx.view] 其实就等于[...
分类:
其他好文 时间:
2015-10-28 21:07:47
阅读次数:
170
layoutSubviews在以下情况下会被调用:1、init初始化不会触发layoutSubviews2、addSubview会触发layoutSubviews3、设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化4、滚动一个UIScrollVi...
分类:
其他好文 时间:
2015-10-25 13:37:14
阅读次数:
147
UIImageView * img = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]; [self.view addSubview:img];NSURL *url = [NSURL URLWithString:@....
分类:
Web程序 时间:
2015-10-24 14:14:38
阅读次数:
174
//类型//创建一个label UILabel *label1=[[UILabel alloc]initWithFrame:CGRectMake(130, 60,250, 150)]; [self.window addSubview:label1]; label1.text=@"评分:7.1 (4....
分类:
其他好文 时间:
2015-10-22 21:28:06
阅读次数:
500
雷达使用UIScrollView做的UIView * contanerView = [[UIView alloc] initWithFrame:self.bounds];[self addSubview:contanerView];_containerView = contanerV...
分类:
其他好文 时间:
2015-10-22 21:16:42
阅读次数:
168
//1.初始化UITextField let userName=UITextField(frame: CGRectMake(0, 100, 100, 100));//2.将文本框userName添加到当前视图中 self.view.addSubview(userName);//3.文本框默认显...
分类:
编程语言 时间:
2015-10-21 20:51:45
阅读次数:
159
UIView *v = [[UIView alloc]initWithFrame:CGRectMake(10, 400, 300, 200)]; // 初始化一个UIView ? ? [v setBackgroundColor:[UIColor redColor]]; // 设置背景颜色 ? ? [self.view addSubview:v]; ...
分类:
其他好文 时间:
2015-10-21 14:14:09
阅读次数:
103
首先两个方法都是异步执行。layoutSubviews方便数据计算,drawRect方便视图重绘。layoutSubviews在以下情况下会被调用:1、init初始化不会触发layoutSubviews。2、addSubview会触发layoutSubviews。3、设置view的Frame会触发l...
分类:
其他好文 时间:
2015-10-21 01:41:04
阅读次数:
185
代码创建按钮:1.创建一个自定义的按钮UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];2.添加按钮[self.view addSubview:btn];3.设置按钮的位置和尺寸btn.frame = CGRectMake(10...
分类:
其他好文 时间:
2015-10-20 01:17:36
阅读次数:
179
1. 基本使用 UIView * view = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 50,50)]; view.backgroundColor = [UIColor orangeColor]; [self.view addSubview.....
分类:
其他好文 时间:
2015-10-14 12:13:33
阅读次数:
217