iOS11以后关于Scrollview偏移问题

在iOS 11上运行Scrollview向下偏移64px或者20px,因为iOS 11废弃了automaticallyAdjustsScrollViewInsets,给UIScrollView增加了contentInsetAdjustmentBehavior属性。解决这个问题我们需要做一下系统判断就可以,Tableview与Collectionview类似的解决方案

    if (@available(iOS 11.0, *)) {
        _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }

你可能感兴趣的:(iOS11以后关于Scrollview偏移问题)