iOS11下导航适配

在iOS11之前:通过下面代码调整导航的位置,来自定义返回的导航

    [[UIBarButtonItem appearance] setTintColor:[UIColor px_greenColor]];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:[[UIImage imageNamed:@"ic_nav_back"] stretchableImageWithLeftCapWidth:-3 topCapHeight:1]
                                                      forState:UIControlStateNormal
                                                    barMetrics:UIBarMetricsDefault];

    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:[[UIImage imageNamed:@"ic_nav_back_highlighted"] stretchableImageWithLeftCapWidth:-3 topCapHeight:1]
                                                      forState:UIControlStateHighlighted
                                                    barMetrics:UIBarMetricsDefault];

    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
                                                         forBarMetrics:UIBarMetricsDefault];

iOS11之后,这个方法已经不适用,系统的导航还是会展示在上面,需要改成下面适配

    UIImage *backButtonImage = [[UIImage imageNamed:@"ic_nav_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [UINavigationBar appearance].backIndicatorImage = backButtonImage;
    [UINavigationBar appearance].backIndicatorTransitionMaskImage = backButtonImage;

你可能感兴趣的:(iOS11下导航适配)