简体   繁体   English

更改UINavigationBar背景图片,并使UINavigationBar缩放

[英]Change UINavigationBar background image and make the UINavigationBar to scale

What is the easiest way to change UINavigationBar background image and make the main UINavigationBar to scale to the background image size? 更改UINavigationBar背景图像并使主UINavigationBar缩放到背景图像尺寸的最简单方法是什么?

I designed a navigation bar that is not the size of my table view controller navigation bar, and now I imported the image to Xcode and I want to do something like: 我设计了一个导航栏,它的大小不是表格视图控制器导航栏的大小,现在我将图像导入到Xcode中,并且想要执行以下操作:

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"BG.png"] forBarMetrics:UIBarMetricsDefault];

but that does not work, anyway I think that this way I will have a problem with the height since my designed nav is bigger. 但这是行不通的,无论如何,我认为这样设计的导航栏会更大,因此我会遇到高度问题。

How can I do this please? 我该怎么做?

It's better to not do that, there are some hacks than you can do, for example hide navigation bar and create a personalized bar with the height you want. 最好不要这样做,因为有很多技巧无法做到,例如隐藏导航栏并创建具有所需高度的个性化栏。

Check this post: https://stackoverflow.com/a/7533098/4559321 检查此帖子: https : //stackoverflow.com/a/7533098/4559321

I recommend to change your design to fit with the standard UINavigationBar and you will save lot of work. 我建议更改您的设计以适合标准的UINavigationBar,这样可以节省很多工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM