0
votes

i have search a lot in the web and on stack overflow and i see that there are a lot of question about this problem, so i want search a solution to this, but i can't find it, i have subclassed the UINavigationBar to use my custom image to my NavigationBar, but is stretched to fill in the size of the navigation bar, how i can increase the height?

this is how i have do, i have crete a Xib file with only a UINavigationController, and then in interface builder i have set My CustomClass for the NavigationBar:

UINib *nib = [UINib nibWithNibName:@"CustomNavigationController" bundle:nil];
UINavigationController *navController = 
[[nib instantiateWithOwner:nil options:nil] objectAtIndex:0];

then my custom class:

@implementation CustomNavigationBar

- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"NavigationBar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

i have tried to change the height here, self.frame.size.height, but the height size don't change, change only my image that is scaled... there is a way to set the size of the navigation bar with my image size?

2

2 Answers

0
votes

Maybe try something like:

- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed:@"NavigationBar.png"];
    self.frame = CGRectMake(0, 0, image.size.width, image.size.height);
    [image drawInRect:self.frame];
}
-1
votes

The height of a navigation bar is fixed. You can't change it. You could roll your own navigation bar by implementing a custom view though.