4
votes

Is it possible to change navigation bar height in iOS 7?

why I need navigation bar: to have a transparent navigation bar with the right positions of others elements on my view without any problems;

I don't want to create a fake "navigation bar" - in this case I'll need to set up all positions myself.

2

2 Answers

3
votes
//make real nav bar invisible
self.navigationBar.barTintColor = [UIColor clearColor];
UIImage* transparentImage = [UIImage emptyImageWithSize:CGSizeMake(self.navigationBar.frame.size.width, 1) andBackgroundColor:[UIColor clearColor]];
[self.navigationBar setBackgroundImage:transparentImage forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = transparentImage;

and then

UINavigationBar* fakeNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0,      self.navigationBar.frame.size.width, neededHeight)];
fakeNavigationBar.barTintColor = [UIColor whiteColor];
[self.navigationBar insertSubview:fakeNavigationBar atIndex:0];

where

+ (UIImage*)emptyImageWithSize:(CGSize)size andBackgroundColor:(UIColor*)color
{
    CGRect frameRect = CGRectMake(0, 0, size.width, size.height);
    UIGraphicsBeginImageContext(size);
    CGContextRef ctx = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(ctx, color.CGColor); //image frame color
    CGContextFillRect(ctx, frameRect);

    UIImage* resultImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return resultImage;
}
1
votes

In your app delegate

UINavigationController *NavController=[[UINavigationController alloc]initWithRootViewController:HomeViewController];
[NavController.navigationBar setBounds:CGRectMake(10, 30, 40, 10)];