在ios 11 系统中
当 UIScrollView,UICollectionView ,UITableView尺寸发生了改变了
设置一下它们ios11新属性
/* Configure the behavior of adjustedContentInset.
Default is UIScrollViewContentInsetAdjustmentAutomatic.
*/
@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior API_AVAILABLE(ios(11.0),tvos(11.0));
// tableView适配ios11
if (@available(iOS 11.0, *)) {
tableView.estimatedRowHeight = 0;
tableView.estimatedSectionFooterHeight = 0;
tableView.estimatedSectionHeaderHeight = 0;
tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
凡是Scrollview 及 Scrollview子类都会有适配问题,整个工程里可以一行代码解决问题:
// AppDelegate 进行全局设置
if(@available(iOS11.0, *)){
[[UIScrollViewappearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
网友评论