设置navigationController一个尺寸为750 × 90图像尺寸的图像
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg.png"] forBarMetrics:UIBarMetricsDefault];
将图像设置到导航 Controller 后,它在 UINavigationController 上未完全绘制图像。
如何在 UINavigationController
栏上设置图像。
最佳答案
试试这个
use the method of resizableImageWithCapInsets:resizingMode: and set the resizingMode to UIImageResizingModeStretch, else the image would still Same in the navigation bar.
UIImage *currentImgae = [[UIImage imageNamed:@"bg.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
[self.navigationController.navigationBar setBackgroundImage:currentImgae forBarMetrics:UIBarMetricsDefault];
swift
let currentImgae = UIImage(named: "bg.png")!.resizableImageWithCapInsets(UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .Stretch)
self.navigationController.navigationBar.setBackgroundImage(currentImgae!, forBarMetrics: .Default)
关于ios - 如何在 UINavigationBar 上设置图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39098389/