iOS 15 返回按钮自定义图片失败问题修复方法

2022-02-17  本文已影响0人  fairy_happy

iOS 15系统 backIndicatorImage图片设置失败问题修复方法
在iOS15之前,我们是这样设置的

UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
navigationBarAppearance.backIndicatorImage = [UIImage imageNamed:@"image_common_navBackBlack"];
navigationBarAppearance.backIndicatorTransitionMaskImage = [UIImage imageNamed:@"image_common_navBackBlack"];

但是系统升级到iOS15之后,发现返回按钮不是自定义的图片了,设置失效,我们需要调整代码如下

if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
        [appearance setBackIndicatorImage:[UIImage imageNamed:@"image_common_navBackBlack"] transitionMaskImage:[UIImage imageNamed:@"image_common_navBackBlack"]];
        [[UINavigationBar appearance].scrollEdgeAppearance: appearance];
        [[UINavigationBar appearance].standardAppearance:appearance];
    }

通过set方法设置,就可以发现返回按钮的图片替换成功了

上一篇下一篇

猜你喜欢

热点阅读