适配iOS11&iPhone X

来源:互联网 发布:python遗传算法库 编辑:程序博客网 时间:2024/04/30 02:36

MJRefresh下拉刷新错乱(refreshheader 一直在页面 上面显示)

如图
这里写图片描述

automaticallyAdjustsScrollViewInsets 在 iOS11 失效。

@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets API_DEPRECATED_WITH_REPLACEMENT("Use UIScrollView's contentInsetAdjustmentBehavior instead", ios(7.0,11.0),tvos(7.0,11.0)); // Defaults to YES

所以

    self.automaticallyAdjustsScrollViewInsets = NO; if (@available(iOS 11.0, *)){        if ([self.bottomScrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {            [self.bottomScrollView setContentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentNever];        }    }

如果在项目中,有很多页面有 scrollView 或这其子类 刷新等
那么直接采用下面的方法

if (@available(iOS 11.0, *)){        [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];    }

因为项目中用到statusbar的设置,所以导致下面页面显示不对

这里写图片描述

修改UINavigationBar+Awesome.m 文件中self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + 20)];

修改:

        self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + [[UIApplication sharedApplication] statusBarFrame].size.height)];

iPhone x 的改变

statusbar : 20 –>44
tabbar : 49 –> 83
这里注意一下:
如果写固定的值的话,那么现在工作来了。666
所以如果要获取 statusbar 的 frame : [[UIApplication sharedApplication] statusBarFrame]
用系统的获取方法,可以以不变应万变、

这里写图片描述

滑动之后
这里写图片描述