UIButton:
1、UIButton对于自定义Button需要设置宽度和高度才能显示,
2、而系统的Button在系统内部设置了宽度高度所以不需要认再去设置,如果人为改变其大小,显示的imageView大小是没有变化,只是Button的大小发生了改变
3、代码如下:
UIButton*button = [UIButton buttonWithType:UIButtonTypeContactAdd];
button.frame = CGRectMake(100, 100, 100, 100);
button.backgroundColor = [UIColor redColor];
[self.view addSubview:button];
NSLog(@"%@",NSStringFromCGRect(button.frame));
UILabel:
1、UILabel 需要设置宽度和高度才能显示
UILabel *lalel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
lalel.backgroundColor = [UIColor redColor];
[self.view addSubview:lalel];
NSLog(@"%@",NSStringFromCGRect(lalel.frame));