简体   繁体   中英

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?

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:

[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

I recommend to change your design to fit with the standard UINavigationBar and you will save lot of work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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