
Untitled
By: a guest on
Jul 14th, 2012 | syntax:
None | size: 1.33 KB | hits: 17 | expires: Never
Navigation Controller not working properly
if([[UINavigationBar class] respondsToSelector:@selector(appearance)]) //iOS >=5.0
{
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
else
{
self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"header.png"].CGImage;
}
UINavigationController *navControl;
UINavigationBar *navBar = self.navControl.navigationBar;
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
imgView.image = [UIImage imageNamed:@"header.png"];
[navBar addSubview:imgView];
[imgView release];
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"background.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
implement this code in your .m file
@implementation ImageViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
UIImageView *backGroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.navigationController.navigationBar insertSubview:backGroundView atIndex:0];
[backGroundView release];
}
@end