美文网首页
iOS 11和iPhone X 的适配

iOS 11和iPhone X 的适配

作者: 扣肉快快跑 | 来源:发表于2017-11-15 13:35 被阅读3次

iOS 11的适配

关于iOS 11设置self.automaticallyAdjustsScrollViewInsets = NO后还是存在向下偏移的问题

    self.automaticallyAdjustsScrollViewInsets = NO;//设置成NO从0开始
    if (@available(iOS 11.0, *)) {
        self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        self.collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);//导航栏如果使用系统原生半透明的,top设置为64
        self.collectionView.scrollIndicatorInsets = self.collectionView.contentInset;
    }

iPhone X的适配

由于iPhone X的状态栏高度发生变化, 设置坐标时建议使用下面代码替换之前的64,20 等

//导航栏搞
#define navigationBarHeight self.navigationController.navigationBar.frame.size.height
//状态栏高
#define statusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
//标签栏高
#define tabBarHeight self.tabBarController.tabBar.frame.size.height
竖屏示意图 横屏示意图

相关文章

网友评论

      本文标题:iOS 11和iPhone X 的适配

      本文链接:https://www.haomeiwen.com/subject/dkbcvxtx.html