zoukankan      html  css  js  c++  java
  • iOS-Masonry用法

     __weak typeof(self) weakSelf = self;
        
        UIView * tempView = [[UIView alloc]init];
        NSInteger count = 10;//设置一排view的个数
        NSInteger margin = 10;//设置相隔距离
        NSInteger height = 50;//设置view的高度
        for (int i = 0; i < count; i ++) {
            UIView * view = [[UIView alloc]init];
            view.backgroundColor = [UIColor brownColor];
            [self.view addSubview:view];
            if (i == 0) {
                [view mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(weakSelf.view).offset(margin);
                    make.centerY.equalTo(weakSelf.view);
                    make.height.mas_equalTo(height);
                }];
            }
            else if (i == count - 1){
                [view mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(weakSelf.view).offset(-margin);
                    make.left.equalTo(tempView.mas_right).offset(margin);
                    make.centerY.equalTo(tempView);
                    make.height.equalTo(tempView);
                    make.width.equalTo(tempView);
                }];
            }
            else{
                [view mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(tempView.mas_right).offset(margin);
                    make.centerY.equalTo(tempView);
                    make.height.equalTo(tempView);
                    make.width.equalTo(tempView);
                }];
            }
            tempView = view;
            [view layoutIfNeeded];
        }
  • 相关阅读:
    走进AngularJs(二) ng模板中常用指令的使用方式
    mysql知识汇总
    存储动态数据时,数据库的设计方法
    js判断密码强度
    svg―Raphael.js Library(一)
    常用js代码
    IE6实现图片或背景的圆角效果
    巧用css border
    IE6下的效果
    理解盒模型
  • 原文地址:https://www.cnblogs.com/WJJ-Dream/p/5787002.html
Copyright © 2011-2022 走看看