美文网首页
iOS 屏幕适配

iOS 屏幕适配

作者: dongfang | 来源:发表于2019-04-11 17:03 被阅读0次

        UIView*topView = [[UIViewalloc]init];

        [self.viewaddSubview:topView];

        topView.backgroundColor= [UIColorgreenColor];

        UIView*bottomView = [[UIViewalloc]init];

        [self.viewaddSubview:bottomView];

        bottomView.backgroundColor= [UIColorgreenColor];

        UITableView *tv = [[UITableView alloc]initWithFrame:CGRectZero];

        tv.delegate=self;

        tv.dataSource=self;

        [self.viewaddSubview:tv];

        tv.backgroundColor = [UIColor redColor];

        NSMutableArray * data = [NSMutableArray array];

        for(inti =0; i <50; i++) {

            [dataaddObject: [NSString stringWithFormat:@"%d",i]];

        }

        _data= data;

        [topViewmas_makeConstraints:^(MASConstraintMaker*make) {


            if(@available(iOS11.0, *)) {

                make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);

            }else{

                make.top.equalTo(self.mas_topLayoutGuide);

            }

            make.height.equalTo(@100);

            make.left.right.equalTo(self.view);

        }];

        [tvmas_makeConstraints:^(MASConstraintMaker*make) {

            make.top.equalTo(topView.mas_bottom);

            make.bottom.equalTo(bottomView.mas_top);

            make.left.right.equalTo(self.view);

        }];

        [bottomViewmas_makeConstraints:^(MASConstraintMaker*make) {

           make.left.right.equalTo(self.view);

            make.height.equalTo(@60);

            if(@available(iOS11.0, *)) {

                make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);

            }else{

                // Fallback on earlier versions

                make.bottom.equalTo(self.bottomLayoutGuide);

            }

        }];

    相关文章

      网友评论

          本文标题:iOS 屏幕适配

          本文链接:https://www.haomeiwen.com/subject/vchdmqtx.html