zoukankan      html  css  js  c++  java
  • 使用自动化布局获取空间的frame

    自动化布局完毕之后,也是进行frame的布局的,所以只需要在layoutIfNeeded之后获取frame就可以了

    UIView *footerview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 1)];
        footerview.backgroundColor = [UIColor blackColor];
        
        UIView *redView = [UIView new];
        redView.backgroundColor = [UIColor redColor];
        [footerview addSubview:redView];
        [redView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-300);
            make.top.left.offset(0);
            make.height.equalTo(@70);
        }];
        
        UIView *blueView = [UIView new];
        blueView.backgroundColor = [UIColor blueColor];
        [footerview addSubview:blueView];
        [blueView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-300);
            make.top.equalTo(redView.mas_bottom).offset(0);
            make.left.offset(0);
            make.height.equalTo(@300);
    //        make.bottom.offset(0);
        }];
        
        //一定要在获取frame之前调用layoutIfNeed
        [footerview layoutIfNeeded];
        footerview.frame = CGRectMake(0, 0, self.view.bounds.size.width, CGRectGetMaxY(blueView.frame));
        NSLog(@"%d",CGRectGetMaxY(blueView.frame));
    
  • 相关阅读:
    属性选择器
    优先级
    hj_html&css
    hj_解决gpedit.msc不存在的问题
    hj_designPatterns
    hj_ssm
    hj-springmvc
    hj_mybatis
    hj_Python踩坑之旅
    hj_Python学习笔记
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/14206661.html
Copyright © 2011-2022 走看看