我正在做这样的事情:
UIImage *barBackgroundImage = [UIImage imageNamed:@"myImage.png"];
[[UINavigationBar appearance] setBackgroundImage:
backgroundImage
forBarMetrics:UIBarMetricsDefault];
并且生成的 UINavigationBar 比标准导航栏大得多。我知道我的图像尺寸可能是问题所在。有没有办法以编程方式解决这个问题?
最佳答案
这就是我设置 UINavigationController
的方式的 navigationBar
背景图。
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setTintColor:LIGHTBROWN];
navbar.png
是 320x44
分别640x88
对于 navbar@2x.png
.
关于objective-c - 为什么设置我的导航栏背景图片会影响导航栏的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10182127/