iOS 导航栏消失
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]]; }
此文章为个人笔记,方便自己以及有需要的朋友查看,转载请注明出处!