我得到了这张图片,我想在我的导航 Controller 中使用它:
我是这样设置的(根据 this 问题的建议):
UINavigationBar *theBar = self.navigationController.navigationBar;
if ( [theBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
UIImage *image = [UIImage imageNamed:@"cabecalho.jpg"];
[theBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
但是当我运行我的应用程序时,我得到了这个:
我该怎么做才能使我的图像适合导航 Controller ?
谢谢。
最佳答案
试试下面的代码
[self.navigationBar setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"myImage.png"]]];
引用How to add background image on iphone Navigation bar?这个问题可能对你有帮助。
关于iphone - 使图像适合 UINavigationBar 栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15778591/