- (void) setNavBarImg:(UINavigationBar *)navBar
{
#define kSCNavBarImageTag 10
if ([navBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
//if iOS 5.0 and later
[navBar setBackgroundImage:[UIImage imageNamed:(@"main_navigation_bg")] forBarMetrics:UIBarMetricsDefault];
}
else
{
UIImageView *imageView = (UIImageView *)[navBar viewWithTag:kSCNavBarImageTag];
[imageView setBackgroundColor:[UIColor clearColor]];
if (imageView == nil)
{
imageView = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:(@"main_navigation_bg")]];
[imageView setTag:kSCNavBarImageTag];
[navBar insertSubview:imageView atIndex:0];
}
}
}
[self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor clearColor]]];//導航欄最下邊線顏色
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];//導航欄字體顏色
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];//導航欄左右兩邊按鈕顏色