• 使用自动化布局获取空间的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));
    
  • 相关阅读:
    线上项目部署
    day26 面向对象 单例模式总结
    阿里云服务器,更换操作系统步骤总结
    后端for循环补充
    前端,css
    django-admin 仿写stark组件action,filter筛选过滤,search查询
    7.20晚作业
    用户和群组管理
    7.19 晚作业
    目录和文件管理
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/14206661.html
Copyright © 2020-2023  润新知