Search code examples
iphoneiosios6.1

UINavigationBar handle rotation


I'm trying to handle the rotation of a UINavigationBar with UINavigationItem (i'm not using the UINavigationController), i have successfully made so that the height and width show according, but that does not seems to be correct, as the UINavigationBar still acts as being in portrait mode (big title and button), also when i set a custom background for both metrics, it seems to only show the portrait background metric, ignoring completely the landscape one.

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"modal-top-landscape"] forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"modal-top"] forBarMetrics:UIBarMetricsDefault];

Is there a way to tell the UINavigationBar that is rotated and should show the text and buttons accordingly?

I attach some screenshots: Portrait OK Landscape big button and tittle Landscape custom background big items and tittle


Solution

  • One workaround for this is to use a UINavigationController, and use a CGRectOffset to remove the margin that leaves the status bar... add the Controller to the parent controller (also the view).