今天做了个界面,没有navigationbar的页面,直接设置了一个(0,0,MainWidth,MainHeight)的ScrollView,然后往里边添加子视图,发现子视图并没有顶到顶部,照网上很多操作都无法,然后,突发奇想进去看了下Scroll的API,发现了这个属性:
@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior API_AVAILABLE(ios(11.0),tvos(11.0));
然后我就用了这个属性,然后…就解决了…
在此作个记录,下面是代码:
if (@available(iOS 11.0, *)) {
scroll.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}