首页 > 其他 > 详细

UIStackView使用 (堆视图)

时间:2016-12-31 15:35:42      阅读:129      评论:0      收藏:0      [点我收藏+]

一基本使用

  1创建多个子控件

   

for (int i = 0; i < 3; i++)
    {
        UIButton *imgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        imgBtn.backgroundColor = [UIColor redColor];
        [imgBtn setNormalImageWithName:@""];
        [imgBtns addObject:imgBtn];
    }

   2创建堆控件

//创建堆控件
    UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:imgBtns];
    [self.view addSubview:stackView];
    [stackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(titleLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(60);
        make.right.mas_equalTo(-60);
        make.height.mas_equalTo(80);
    }];

 

  3设置属性

stackView.axis = UILayoutConstraintAxisHorizontal;
stackView.distribution = UIStackViewDistributionFillEqually;
stackView.spacing = 35;

 

  

UIStackView使用 (堆视图)

原文:http://www.cnblogs.com/dzq1991/p/6239329.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!