iOS11导航栏返回键适配

2017-12-19  本文已影响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];
}
上一篇 下一篇

猜你喜欢

热点阅读