美文网首页
iOS11导航栏返回键适配

iOS11导航栏返回键适配

作者: 幻想无极 | 来源:发表于2017-12-19 15:14 被阅读18次

    iOS11后设置返回键文字消失方法失效了

    - (void)setBackButtonTitlePositionAdjustment:(UIOffset)adjustment forBarMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR __TVOS_PROHIBITED;
    

    网上偏方太多了,我这写下我的偏方吧
    在导航栏控制器中重写push方法

    - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        if (self.viewControllers.count > 0) {
            viewController.hidesBottomBarWhenPushed = YES;
            viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:IMAGE(@"mouo_nav_return") style:UIBarButtonItemStylePlain target:self action:@selector(backButtonEvent)];
        }
        [super pushViewController:viewController animated:animated];
    }
    
    #pragma mark - 事件监听
    
    - (void)backButtonEvent {
        [self popViewControllerAnimated:YES];
    }
    

    相关文章

      网友评论

          本文标题:iOS11导航栏返回键适配

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