自定义AlertView

来源:4-12 自定义AlertView

Gfield03

2017-05-16 19:50:08

UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, 50)];

为什么不是self.frame

写回答

1回答

Tender10

2017-05-17

因为自定义AlertView会重写它的initWithframe方法,在这个方法中后面有一个参数就是frame,这里设置label的位置时,需要设置宽度,就是frame参数进行设置的。self代表的是当前的对象,如果是添加一个UILable到UIView上,就会用当前self这个View的位置,但是现在重写了initWithFrame方法,后面是有frame参数的,就不需要加self了,直接使用这个参数即可。

0

0 学习 · 1878 问题

查看课程