iOS15 导航栏在静止时,设置的图片会透明,以及消失。
解决如下
if (@available(iOS 13.0, *)) { UINavigationBarAppearance *appearance = [UINavigationBarAppearance new]; UIImage *backGroundImage = [UIImage imageNamed:@"home_nav_imgV"]; backGroundImage = [backGroundImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch]; appearance.backgroundImage = backGroundImage; appearance.shadowColor = [UIColor clearColor]; appearance.shadowImage = [UIImage new]; self.navigationController.navigationBar.standardAppearance = appearance; self.navigationController.navigationBar.scrollEdgeAppearance = self.navigationController.navigationBar.standardAppearance; } else { UIImage *backGroundImage = [UIImage imageNamed:@"home_nav_imgV"]; backGroundImage = [backGroundImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch]; [self.navigationController.navigationBar setBackgroundImage:backGroundImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:[UIImage new]]; }