Switching to iOS5, I wanted to make use of a custom styled UINavigationBar using the following code snippet:
if ([navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:
forBarMetrics:)]) {
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBar.png"]
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBarLandscape.png"]
forBarMetrics:UIBarMetricsLandscapePhone];
}
This works quite well, but: my custom image has rounded corners (c.f. the attached images) which causes the following:
Starting in portrait mode, it looks fine.

Changing to landscape mode also looks good.

Changing back to portrait mode however does not seem to change the image to NavigationBar.png, thus there is no rounded corner on the top right.

Any advice on how to solve this problem is appreciated.
// edit
Adding the following code to my viewController removes this “bug” but this cannot be the right solution!?!
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation
duration:duration];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBar.png"]
forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBarLandscape.png"]
forBarMetrics:UIBarMetricsLandscapePhone];
}
As iOS6 introduces rounded corners by default, this problem will disappear soon.