zoukankan      html  css  js  c++  java
  • UIStackView使用 (堆视图)

    一基本使用

      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;
    

      

  • 相关阅读:
    20201107
    20201024
    20201020
    20200331
    20200330
    20200320
    20200319
    20200310
    20200221
    20190926
  • 原文地址:https://www.cnblogs.com/dzq1991/p/6239329.html
Copyright © 2011-2022 走看看