我曾尝试使用以下代码来设置 UINavigationBar
的背景图片。
它在 Xcode 9 之前工作正常,但在 Xcode 9 中图像设置不正确。
UIImage *image = [UIImage imageNamed:@"headr_bg"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
最佳答案
可能不是完美的解决方案& 但是我有一个旧项目,因为我已经通过下面的代码修复了它。刚刚为 iOS 版本 > 11 更新了导航栏位置和导航 View 框架。
CGRect navbarFrame = self.navigationController.navigationBar.frame;
CGRect navFrame = self.navigationController.view.frame;
navbarFrame.size.height = 44;
navFrame.origin.y = 20;
self.navigationController.navigationBar.frame = navbarFrame;
self.navigationController.view.frame = navFrame;
关于ios - 导航 Controller 背景图像使用 xcode 9 在 ios 11 中 self 重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46557827/