|
// |
|
// CCustomNavigationBar.m |
|
// |
|
// Created by Tom Mulder on 05-12-11. |
|
// Copyright (c) 2011 Reed Business. All rights reserved. |
|
// |
|
|
|
#import "CCustomNavigationBar.h" |
|
|
|
@implementation CCustomNavigationBar |
|
|
|
- (id)init |
|
{ |
|
if ((self = [super init])) |
|
{ |
|
[self.navigationBar setTintColor:[UIColor colorWithRed:231.0/255.0 green:87.0/255.0 blue:65.0/255.0 alpha:1.0]]; |
|
|
|
|
|
if ([self.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) |
|
{ |
|
[self.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBar"] forBarMetrics:UIBarMetricsDefault]; |
|
} |
|
else |
|
{ |
|
UIImageView *imageView = (UIImageView *)[self.navigationBar viewWithTag:kCCNavBarImageTag]; |
|
if (imageView == nil) |
|
{ |
|
imageView = [[UIImageView alloc] initWithImage: |
|
[UIImage imageNamed:@"NavigationBar"]]; |
|
[imageView setTag:kCCNavBarImageTag]; |
|
[imageView setFrame:CGRectMake(0, 0, |
|
self.navigationBar.frame.size.width, self.navigationBar.frame.size.height)]; |
|
[self.navigationBar insertSubview:imageView atIndex:0]; |
|
[imageView release]; |
|
} |
|
|
|
} |
|
|
|
} |
|
return self; |
|
} |
|
|
|
- (UIModalPresentationStyle)modalPresentationStyle |
|
{ |
|
if ([self topViewController]) |
|
{ |
|
return [[self topViewController] modalPresentationStyle]; |
|
} |
|
else |
|
{ |
|
return [super modalPresentationStyle]; |
|
} |
|
} |
|
|
|
- (void)updateNavBarBackground |
|
{ |
|
[[self.navigationBar viewWithTag:kCCNavBarImageTag] setFrame:CGRectMake(0, 0, |
|
self.navigationBar.frame.size.width, self.navigationBar.frame.size.height)]; |
|
} |
|
|
|
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation |
|
{ |
|
[self updateNavBarBackground]; |
|
} |
|
|
|
@end |