Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change iPhone navigation bar's height

My client can't read iPhone's default fonts, the size is too small. I have an application with a navigation bar and I need to make everything in it bigger, for example, the font's size.

IB doesn't seem to allow this... any help?

Many thanks!

like image 882
Hectoret Avatar asked May 21 '09 13:05

Hectoret


2 Answers

Update: today (2012) there is a much bigger tendency towards custom UIs, so I would say the answer below is way too harsh. There is still no supported way of customizing height, though, but you can certainly derive from UINavigationBar and override some sizing methods. This probably will not get you rejected (although it is still a grey area, just something Apple will probably overlook today).

Once you get the size you want, you can use iOS 5 customization APIs to add the custom background image (see WWDC 2011 Session 114 - Customizing the Appearance of UIKit Controls).

Original answer from 2009:

This is generally impossible.

What's more, I believe making the navigation bar taller is a violation of Apple Human Interface Guidelines, and your application may be rejected from the App Store because of it. Please make sure your client understands this risk before proceeding.

(Pointing out rejection risks is usually a good way to convince clients against making nonsense decisions.)

like image 76
Andrey Tarantsov Avatar answered Sep 18 '22 03:09

Andrey Tarantsov


Many of the answers here are incorrect, or incomplete, so I wanted to add my answer here in the hope that it might enlighten some.

First off, there is nothing wrong with changing the height of the navigation bar. People commenting saying its not allowed, or goes against the guidelines are simply misunderstanding those guidelines.

The ability to adjust or alter the default navigation bar that's used inside a UINavigationController has been part of the SDK since iOS 5.

- (instancetype)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass NS_AVAILABLE_IOS(5_0);

The easiest way to change the height of the status bar is to use this method when initialising your navigation controller, passing in your custom UINavigationBar sub-class.

TestViewController *t = [[TestViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithNavigationBarClass:[MyNavigationBar class] toolbarClass:[UIToolbar class]];
[nav setViewControllers:@[t]];  
[self.window setRootViewController:nav];
[self.window makeKeyAndVisible];

Where an example of such a custom UINavigationBar class could look like:

@interface MyNavigationBar : UINavigationBar
@end

@implementation MyNavigationBar

- (CGSize)sizeThatFits:(CGSize)size
{
        CGSize s = [super sizeThatFits:size];
        s.height = 90; // Or some other height
        return s;
}

@end
like image 38
Skela Avatar answered Sep 19 '22 03:09

Skela