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);

        }];

        

  • 相关阅读:
    maven .assembly
    命令参数解析库JCommonder
    OWL,以及XML,RDF
    Ambari是什么?
    上海新桥>风景服务区>宁波江东区车管所 及返程路线
    武汉旅游地图(zz)
    武汉旅游(zz)
    上海市松江区 <> 上海市金山区枫泾·万枫东路ab6177,racehttp://live.racingchina.com/
    明中路明华路到第九人民医院路线
    月台路春申塘桥到虹桥火车站
  • 原文地址:https://www.cnblogs.com/huaida/p/11233211.html
Copyright © 2011-2022 走看看