Custom background for UINavigationBar in landcape mode
Posted
by lostInTransit
on Stack Overflow
See other posts from Stack Overflow
or by lostInTransit
Published on 2008-12-19T09:33:36Z
Indexed on
2010/04/20
13:03 UTC
Read the original article
Hit count: 472
iphone
|uinavigationbar
Hi
I am adding a custom background for my UINavigationBar. It works fine as long as the phone is in portrait mode. As soon as I switch to landscape mode, half the bar appears blue (the default navbar color) and half of it has my image
How can I stretch the image for landscape mode and make it small again for portrait mode?
Thanks
Solution
Incase anyone is looking for an answer to how to add an image to navigation bar - here goes
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 480.0, 44.0)];
[imgView setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"navbar_landscape" ofType:@"png"]]];
[navigationController.navigationBar addSubview:imgView];
[imgView release];
© Stack Overflow or respective owner