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);
}
}];
网友评论