Question

Im using a typical situation with UINavigationController, id like to make the navigation bar a bit taller. setting its bounds and frame dont seem to make a difference, im using this code

    //set up the navigation
UINavigationController *navigationController = [UINavigationController new];

[navigationController.navigationBar setBarStyle:UIBarStyleBlack];
[navigationController.navigationBar setTintColor:[UIColor purpleColor]];
[navigationController.navigationBar setBounds:CGRectMake(0.0, 0.0, 480.0, 100.0)];
[navigationController.navigationBar setFrame:CGRectMake(0.0, 0.0, 480.0, 100.0)];

but to no avail. any ideas?

Was it helpful?

Solution

I don't think you can change the height of a navigation bar. Except when you add a prompt message... But that's not what you want.

Frame is the visible area of a view. Bounds is the internal area. Usually this has an origin of (0, 0) and is as wide and high as the frame. However, when the content exceeds the visible area (like with a UIScrollView) the bounds can be larger (and the origin different). You rarely see bounds that are smaller than their respective frames.

EDIT: Looking at your code, what is [UINavigationController new] about? You should do [[UINavigationController alloc] init], shouldn't you?

Also, what you are doing is not really subclassing...

OTHER TIPS

At the time of 2009, there is probably no way to change the height of UINavigationController. However, in iOS SDK 4.3, there is a way (hack).

To change the height of UINavigationController, change its frame size in viewWillAppear:animated: function. Then, the height will stay customized throughout whole app.

As far as I know the standard navigation bar height should not be changed.

"Specifically, it is alright to modify the barStyle, tintColor, and translucent properties, but you must never directly change UIView-level properties such as the frame, bounds, alpha, or hidden properties directly."

If you like to customize the appearance of navigation bar you can use the appearance proxy [UINavigationBar appearance] in iOS 5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top