美文网首页
适配iPhone X在push时tabBar往上偏移的问题

适配iPhone X在push时tabBar往上偏移的问题

作者: 宇玄丶 | 来源:发表于2017-10-10 09:08 被阅读0次

在UINavigationController的基类重写pushViewController代理方法,在push的时候修改一下tabBar的frame。

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count > 0) {
        if ([viewController conformsToProtocol:@protocol(XYTransitionProtocol)] && [self isNeedTransition:viewController]) {
            viewController.hidesBottomBarWhenPushed = NO;
        }else {
            viewController.hidesBottomBarWhenPushed = YES;
        }
    }
    [super pushViewController:viewController animated:animated];
    // 修改tabBar的frame
    CGRect frame = self.tabBarController.tabBar.frame;
    frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
    self.tabBarController.tabBar.frame = frame;
}

相关文章

网友评论

      本文标题:适配iPhone X在push时tabBar往上偏移的问题

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