zoukankan      html  css  js  c++  java
  • UIStackView上手教程

    https://www.jianshu.com/p/19fbf3ee2840

    https://www.cnblogs.com/bokeyuanlibin/p/5693575.html

    https://www.cnblogs.com/breezemist/p/5776552.html

    对于宽度不一致的SubViews ,需要用约束控制其自定义的宽度or高度 ,可以用masonry

    例子:

    UIStackView *stackContainerView = [[UIStackView alloc] init];

        self.stackContainerView = stackContainerView;

        stackContainerView.axis = UILayoutConstraintAxisHorizontal;

        stackContainerView.spacing = 4 ;

        stackContainerView.alignment = UIStackViewAlignmentFill;

        stackContainerView.distribution = UIStackViewDistributionEqualSpacing;

        [self.contentView addSubview:stackContainerView];

        

        CGFloat stackViewWidth = 0;

    //    创建标签view

        

        for (int i = 0; i < self.recommendModel.marketing.count; i ++) {

           

                NSString *tagKey = self.recommendModel.marketing[i];

                MZTagView *tagview = [[MZTagView alloc] initWithTagKey:tagKey];

                [stackContainerView addArrangedSubview:tagview];

                [tagview mas_makeConstraints:^(MASConstraintMaker *make) {

                    make.centerY.equalTo(stackContainerView);

                    make.width.mas_equalTo(tagview.tagViewWidth);

                    make.height.mas_equalTo( 20 *MZ_RATE);

                }];

                

                stackViewWidth += tagview.tagViewWidth;

            

            

        }

        stackViewWidth += (self.recommendModel.marketing.count-1)*4;

        [stackContainerView mas_makeConstraints:^(MASConstraintMaker *make) {

            make.centerY.equalTo(self.avatorView);

            make.width.mas_equalTo(stackViewWidth);

            make.height.mas_equalTo(20 );

            make.right.equalTo(self.contentView).offset(-16);

        }];

        

  • 相关阅读:
    Java微信二次开发(八)
    Java微信二次开发(七)
    Java微信二次开发(六)
    Java微信二次开发(五)
    Java微信二次开发(四)
    Java微信二次开发(三)
    IIS中X509Certificate遇见的问题
    SQL Server 数据库定时自动备份
    ASP.NET 5 (vNext) 理解和概述
    ASP.NET 5 (vNext) Linux部署
  • 原文地址:https://www.cnblogs.com/huaida/p/11233211.html
Copyright © 2011-2022 走看看