zoukankan      html  css  js  c++  java
  • Masonry

    - (void)viewDidLoad {
        [super viewDidLoad];
    
        UIView * redView = [[UIView alloc]init];
        redView.backgroundColor = [UIColor redColor];
        [self.view addSubview:redView];
        
        UIView * blueView = [[UIView alloc]init];
        blueView.backgroundColor = [UIColor blueColor];
        [self.view addSubview:blueView];
        
        UIView * greenView = [[UIView alloc]init];
        greenView.backgroundColor = [UIColor greenColor];
        [self.view addSubview:greenView];
        
        self.redView = redView;
        self.blueView = blueView;
        self.greenView = greenView;
    
        [self.redView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.bottom.equalTo(self.view);
            make.height.equalTo(@80);
            make.width.equalTo(self.blueView);
            make.width.equalTo(self.greenView);
            make.right.equalTo(self.blueView.mas_left);
        }];
        
        [self.blueView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.and.width.and.height.equalTo(self.redView);
            make.left.equalTo(self.redView.mas_right);
            make.right.equalTo(self.greenView.mas_left);
        }];
        
        [self.greenView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.and.width.and.height.equalTo(self.redView);
            make.left.equalTo(self.blueView.mas_right);
            make.right.equalTo(self.view);
        }];
    }

    UILabel * testLabel = [[UILabel alloc]init];
        testLabel.backgroundColor = [UIColor lightGrayColor];
        testLabel.text = @"我要好好学习";
        [self.view addSubview:testLabel];
        [testLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view);
            make.bottom.equalTo(self.redView.mas_top);
        }];//不设置宽和高也可以
    

      

      就不用写viewWillapear了

  • 相关阅读:
    Mybatis源码中最重要的几个类
    学习爬虫-运营商积分
    IntelliJ IDEA 最新版 2019.2.4 激活 (持续更新)(含windows和Mac)
    归并排序之求小和
    归并排序
    理解递归
    插入排序
    对数器
    冒泡排序
    mysql 数据库名称,中间带有中划线问题
  • 原文地址:https://www.cnblogs.com/tanglimei/p/5007757.html
Copyright © 2011-2022 走看看