iOS 11和iPhone X 的适配

2017-11-15  本文已影响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
竖屏示意图 横屏示意图
上一篇 下一篇

猜你喜欢

热点阅读