当升级到iOS 11的时候,发现UIScrollView 有莫名其妙的偏移了 可是明明设置了
automaticallyAdjustsScrollViewInsets
这是因为iOS 11为UIScrollView 添加了新的属性contentInsetAdjustmentBehavior 这是一个枚举
swift
if #available(iOS 11.0, *) {
scrollView.contentInsetAdjustmentBehavior = .never
} else {
// Fallback on earlier versions
}
oc
if (@available(iOS 11.0, *)) {
Scrollview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
// Fallback on earlier versions
}