您的位置:首页 > 产品设计 > UI/UE

UIButton和UILabel的宽与高

2016-07-04 17:31 423 查看
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));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UIButton UILabel