1. 程式人生 > >scrollView在iOS11上出現位置偏移的問題

scrollView在iOS11上出現位置偏移的問題

在iOS11上定義scrollVIew, 內容檢視會出現位置偏移的現象.
無論是iPhone X或者iPhone 8 Plus等

解決方法:

if (@available(iOS 11.0, *)) {
self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
NSLog(@“11.0f”);
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
NSLog(@“10f”);
}

新增上述程式碼即可