Masonry-几个控件的间距相等

    NSArray *titles = @[@"123", @"5555555555", @"12312313", @"666"];
    int count = 4;
    UIView *firstPlaceHolderView = nil;
    MASViewAttribute *leftAttribute = self.view.mas_left;
    for (int i = 0; i < count; i++) {
        
        UILabel *label = [UILabel new];
        label.text = titles[i];
        label.textColor = [UIColor blackColor];
        label.backgroundColor = [UIColor orangeColor];
        [self.view addSubview:label];
        
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(leftAttribute);
            make.top.mas_equalTo(200);
            if (i == count - 1) {
                make.right.equalTo(self.view);
            }
        }];
        
        
        
        if (i < count - 1) {
            UIView *placeHolderView = [UIView new];
            placeHolderView.backgroundColor = [UIColor grayColor];
            [self.view addSubview:placeHolderView];
            [placeHolderView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.bottom.equalTo(label);
                make.left.equalTo(label.mas_right);
                if (firstPlaceHolderView) {
                    make.width.equalTo(firstPlaceHolderView);
                }
            }];
            
            firstPlaceHolderView = placeHolderView;
            leftAttribute = placeHolderView.mas_right;
        }
    }
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.下载支付宝的SDK,建议下载之前的版本,最近更新的版本,按照文档集成完,会出现:支付密码输入完成后,提示“暂时...
    离离乱惑阅读 7,075评论 0 0
  • 股市作为一个利益的竞技场,既是多空双方的争战地,也是投资者心理与智慧的较量场。而每一个回合的较量,都一一写在了盘面...
    谷壬峻阅读 4,940评论 0 2
  • 初见摩羯的人很容易被他阴沉执着的表现所慑。他是严谨的、不苟言笑的、实事求是的,常会给人严肃不可冒犯的感觉,就像黑咖...
    土大鱼阅读 2,586评论 0 0

友情链接更多精彩内容