iOS translucent automaticallyAdjustsScrollViewInsets edgesForExtendedLayout contentInsetAdjustmentBehavior

青春壹個敷衍的年華 提交于 2020-02-17 17:00:14

translucent

       self.navigationController.navigationBar.translucent = NO;

       ios7 之后iOS7之后由于navigationBar.translucent默认是YES,原点在(0,0)点

       当设置NO的时候,原点坐标在(0,64)点开始,屏幕会多一个导航栏的高度

automaticallyAdjustsScrollViewInsets

       self.automaticallyAdjustsScrollViewInsets = NO;

       self.edgesForExtendedLayout = UIRectEdgeNone;

contentInsetAdjustmentBehavior

iOS11中automaticallyAdjustsScrollViewInsets方法被废弃,我们需要使用UIScrollView的 contentInsetAdjustmentBehavior 属性来替代它.
我们先来看看contentInsetAdjustmentBehavior这个枚举值:

typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {
    UIScrollViewContentInsetAdjustmentAutomatic, 和scrollableAxes一样,scrollView会自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动时,也会设置内边距.
    UIScrollViewContentInsetAdjustmentScrollableAxes, //自动计算内边距.
    UIScrollViewContentInsetAdjustmentNever, //不计算内边距,
    UIScrollViewContentInsetAdjustmentAlways, //根据safeAreaInsets 计算内边距
} API_AVAILABLE(ios(11.0),tvos(11.0));self.navigationController.navigationBar.translucent = NO; 相当于self.automaticallyAdjustsScrollViewInsets = NO;self.edgesForExtendedLayout = UIRectEdgeNone;相当于 UIScrollViewContentInsetAdjustmentNever
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!