开发者

how do I change the UINavigationBar's height

This issue has crippled me for over a day. I need to modify the UINavigationBar's height.

The UINavi开发者_StackOverflow中文版gationController is created in the AppDelegate like so.

self.navigationController = [[UINavigationController alloc] initWithRootViewController:mainController];
[self.window addSubview:self.navigationController.view];
[self.window makeKeyAndVisible];

The height of the navbar WILL change and stick if I add [self.navigationController.navigationBar setFrame:newFrame] to viewDidAppear like the code below.

- (void)viewWilAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    CGRect newFrame = CGRectMake(0, 0, 320, 100);
    [self.navigationController.navigationBar setFrame:newFrame]
}

HOWEVER, if I do it this way, you can actually see the frame snapping from the original 44px to a 100px height in the split second that the view loads, which is very annoying.

I've tried adding the [navBar setFrame:] to viewDidload, viewWillAppear of the rootViewController and also the AppDelegate just after I initiate the UINavigationController. None of these work.

Just so you know, I've overridden the drawRect:(CGRect)rect method in a UINavigationBar category to make the background color solid black using the code below but I don't think that has something to do with the problem.

[[UIColor blackColor] set];
CGContextFillRect(UIGraphicsGetCurrentContext(), rect);

Does anyone know the best way to do this?


"Use a toolbar instead of a navigation bar if you need to offer a larger set of controls, or you do not need to enable navigation." - From the iOS Human Interface Guidelines under Navigation Bar / Guidelines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜