您的位置:首页 > 移动开发 > IOS开发

适配iOS11&iPhone X

2017-10-31 13:58 267 查看

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]

用系统的获取方法,可以以不变应万变、



滑动之后

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 适配