适配iOS 11:
Swift :
if #available(iOS 11.0,*){
UIScrollView.appearance().contentInsetAdjustmentBehavior = .never
} else {
self.automaticallyAdjustsScrollViewInsets = false
}
使用tableView时 如果出现section头部或尾部间隙过大时,可以对tableView的属性做修改
if #available(iOS 11.0,*){
tableView.estimatedSectionFooterHeight = 0.01
tableView.estimatedSectionHeaderHeight = 0.01
}
OC :
if (@available (iOS 11.0, *)) {
[[UIScrollView appearance] setContentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentNever];
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
//对于tableView
if (@available (iOS 11.0, *)){
tableView.estimatedSectionFooterHeight = 0.01
tableView.estimatedSectionHeaderHeight = 0.01
}
iPhone X简单适配:
配置全屏(1125x2436)的启动图(launchImage)
部分app可能会出现tableView的headerView或者footerView过大,需要实现DataSource中如下方法
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;