当页面中同时有navigationBar和tabbar时,tableView向上滑到底部的时候则会出现一段空白,但是向下滑的时候是没有空白的,具体效果如下图:
我把tableview的背景颜色设置为了绿色
这个时候设置automaticallyAdjustsScrollViewInsets = NO; 效果如下:
我们看到多出绿色的部分已经没有了。
官方文档解释如下:
A Boolean value that indicates whether the view controller should automatically adjust its scroll view insets.
Declaration
SWIFT
var automaticallyAdjustsScrollViewInsets: Bool
OBJECTIVE-C
@property(nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets
Discussion
The default value of this property is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.
Availability
Available in iOS 7.0 and later.
简单点说就是automaticallyAdjustsScrollViewInsets根据按所在界面的status bar,navigationbar,与tabbar的高度,自动调整scrollview的 inset,设置为no,不让viewController调整,我们自己修改布局即可。
网友评论