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了

  • 相关阅读:
    VIJOS P1057盖房子 (动态规划)
    RQNOJ PID57 / 找啊找啊找GF
    RQNOJ PID302 / [NOIP2001]统计单词个数 (动态规划)
    hdu 3829 Cat VS Dog 最大独立集
    并查集 找k颗树使节点数最多
    在 Sublime Text 3 中配置编译和运行 Java 程序
    在 Sublime Text 3 中配置编译和运行 Java 程序
    StarUML license key
    StarUML license key
    测试对于list的sort与sorted的效率
  • 原文地址:https://www.cnblogs.com/tanglimei/p/5007757.html
Copyright © 2011-2022 走看看