zoukankan      html  css  js  c++  java
  • Masonry 练习

    //
    //  secondViewController.m
    //  test
    //
    //  Created by bytedance on 2021/1/20.
    //
    
    #import "secondViewController.h"
    #import <Masonry/Masonry.h>
    @interface secondViewController ()
    
    @end
    
    @implementation secondViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        self.view.backgroundColor=[UIColor whiteColor];
        CGFloat baseoffset=80;
        CGFloat margin=10;
        UIView *viewOne=[[UIView alloc]init];
        [self.view addSubview: viewOne];
        viewOne.backgroundColor=[UIColor redColor];
        [viewOne mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view).offset(baseoffset+margin);
            make.width.mas_equalTo(self.view).multipliedBy(0.55);
            make.height.mas_equalTo(self.view).multipliedBy(0.2);
            make.left.equalTo(self.view).offset(margin);
        }];
        UIView *viewTwo=[[UIView alloc]init];
        [self.view addSubview:viewTwo];
        viewTwo.backgroundColor=[UIColor blueColor];
        [viewTwo mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(viewOne.mas_bottom).offset(margin);
            make.left.and.width.equalTo(viewOne);
            make.height.equalTo(viewOne).multipliedBy(0.7);
        }];
        UIView *viewThree=[[UIView alloc]init];
        [self.view addSubview:viewThree];
        viewThree.backgroundColor=[UIColor yellowColor];
        [viewThree mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(viewTwo.mas_bottom).offset(margin);
            make.left.equalTo(self.view).offset(margin);
            make.right.equalTo(self.view).offset(-margin);
            make.height.equalTo(self.view).multipliedBy(0.3);
        }];
        UIView *viewFour=[[UIView alloc]init];
        [self.view addSubview:viewFour];
        viewFour.backgroundColor=[UIColor orangeColor];
        [viewFour mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(viewThree).offset(margin);
            make.bottom.mas_equalTo(viewThree.mas_bottom).offset(-margin);
            make.width.equalTo(viewThree.mas_width).multipliedBy(0.28);
        }];
        UIView *viewFive=[[UIView alloc]init];
        [self.view addSubview:viewFive];
        viewFive.backgroundColor=[UIColor whiteColor];
        [viewFive mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(viewFour.mas_right);
            make.top.and.bottom.equalTo(viewFour);
            make.right.equalTo(viewThree).offset(-margin);
        }];
        UIView *viewSix=[[UIView alloc]init];
        [viewFive addSubview:viewSix];
        viewSix.backgroundColor=[UIColor grayColor];
        [viewSix mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.and.left.equalTo(viewFive).offset(margin);
            make.bottom.equalTo(viewFive).offset(-margin);
            make.width.equalTo(viewFive).multipliedBy(0.50);
        }];
        UIView *viewSeven =[[UIView alloc]init];
        [self.view addSubview:viewSeven];
        viewSeven.backgroundColor=[UIColor blackColor];
        [viewSeven mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.and.bottom.equalTo(viewSix);
            make.left.equalTo(viewSix);
            make.right.equalTo(viewSix).offset(-2.0*margin);
        }];
    }
    
    /*
    #pragma mark - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */
    
    @end
    
    
  • 相关阅读:
    微信小程序排坑
    webpack——3.x版本总结
    干货网站
    转码器babel
    es6——之初体验
    移动端适配不同屏幕分辨率——rem布局
    vuejs学习总计——数据传值篇
    vue.js学习总计---路由篇
    vuejs学习总结---基础篇
    vuejs搭建的项目对于ie浏览器的处理
  • 原文地址:https://www.cnblogs.com/liuquanxu/p/14304934.html
Copyright © 2011-2022 走看看