UIButton和UILabel的宽与高

来源:互联网 发布:男士护肤推荐 知乎 编辑:程序博客网 时间:2024/06/06 01:30

UIButton

1UIButton对于自定义Button需要设置宽度和高度才能显示,

2、而系统的Button在系统内部设置了宽度高度所以不需要认再去设置,如果人为改变其大小,显示的imageView大小是没有变化,只是Button的大小发生了改变

3、代码如下:

  UIButton*button = [UIButtonbuttonWithType:UIButtonTypeContactAdd];

    button.frame = CGRectMake(100, 100, 100, 100);

    button.backgroundColor = [UIColorredColor];

    [self.viewaddSubview:button];

    NSLog(@"%@",NSStringFromCGRect(button.frame));

UILabel

1UILabel需要设置宽度和高度才能显示

    UILabel *lalel = [[UILabelalloc] initWithFrame:CGRectMake(100,100, 100, 100)];

   lalel.backgroundColor = [UIColorredColor];

    [self.viewaddSubview:lalel];

    NSLog(@"%@",NSStringFromCGRect(lalel.frame));

0 0
原创粉丝点击