
在隐藏导航栏的情况下设置
self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
if (@available(iOS 11.0, *)){
self.tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
注:
contentInsetAdjustmentBehavior是UIScrollView的属性所以应该是UIScrollView顶部留白问题
或者设置
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
网友评论