美文网首页
第三方自动布局框架--Masonry

第三方自动布局框架--Masonry

作者: Lee_M | 来源:发表于2016-06-01 17:13 被阅读34次

    这个框架方便简单

    框架连接:https://github.com/SnapKit/Masonry
    参考于:http://www.th7.cn/Program/IOS/201502/390670.shtml

    使用时直接导入头文件即可Masonry.h

    - (void)viewDidLoad {
      
        [super viewDidLoad];
        
        [self addMasory];
        
    }
    -(void)addMasory
    {
    
        UIView *view1=[UIView new];
        [view1 setBackgroundColor:[UIColor redColor]];
        [self.view addSubview:view1];
        UIView *view2=[UIView new];
        [view2 setBackgroundColor:[UIColor blackColor]];
        [self.view addSubview:view2];
        
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(30);
        make.bottom.equalTo(self.view.mas_bottom).offset(-30);
        make.right.equalTo(view2.mas_left).offset(-30);
        make.height.mas_equalTo(50);
        
    }];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(-30);
        make.bottom.equalTo(view1.mas_bottom);
        make.height.equalTo(view1.mas_height);
        make.width.equalTo(view1.mas_width);
    }];
        
    }
    

    实现的效果如图:

    2AC10412-3198-44E4-BA4B-D22FF86E79D2.png

    相关文章

      网友评论

          本文标题:第三方自动布局框架--Masonry

          本文链接:https://www.haomeiwen.com/subject/jnmhdttx.html