I have created a custom navigation Bar
#import "UICustomNavigationBar.h"
@implementation UICustomNavigationBar
- (void)drawRect:(CGRect)rect {
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, self.bounds , [UIImage imageNamed:@"capitonhaut.png"].CGImage);
if(UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
{
CGContextDrawImage(context, CGRectMake(155, 5, 170, 37), [UIImage imageNamed:@"logo_BEST.png"].CGImage);
}
else {
CGContextDrawImage(context, CGRectMake(75, 5, 170, 37), [UIImage imageNamed:@"logo_BEST.png"].CGImage);
}
}
@end
Than in my AppDelegate I have
UICustomNavigationBar *navBar = [[UICustomNavigationBar alloc]initWithFrame:CGRectMake(0, 0, self.window.bounds.size.width,50)];
[self.window sendSubviewToBack:self.tabBar.view];
[self.window addSubview:navBar];
[navBar release];
I try to add buttons in some pages like this
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Ok",@"Ok") style:UIBarButtonItemStyleBordered target:self action:@selector(onSortButtonTap:)]];
When I din not have custom navigation bar this code worked.
Thanks
Raluca