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
    
    
  • 相关阅读:
    投票协议:二进制表示方法
    投票协议:构建和解析协议消息
    多任务处理:多线程
    通信:成帧与解析
    通信:组合输入输出流
    跨越FSO WSH写文件
    MS07004漏洞
    解决ASP(图像)上传漏洞的方法
    让硬件入侵不再是神话
    解决ASP(图像)上传漏洞的方法
  • 原文地址:https://www.cnblogs.com/liuquanxu/p/14304934.html
Copyright © 2011-2022 走看看