Created
August 14, 2014 09:27
-
-
Save SmallBlackCat/4f6a468cbd4f80161cd3 to your computer and use it in GitHub Desktop.
Custom Navgaion Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 配置自定义NavigationBar | |
- (void) setupCustomNavigaionBar | |
{ | |
// iOS 7 or Later | |
if (is_IOS7OrLater) { | |
// 图片背景 | |
[[UINavigationBar appearance] setBackgroundImage:[UIImage UIImageFromeColor:[UIColor colorWithRed:0.33 green:0.63 blue:0.7 alpha:1] withSize:CGSizeMake(0, 1)] forBarMetrics:UIBarMetricsDefault]; | |
// 背景颜色 | |
[[UINavigationBar appearance] setBarTintColor:Button_Backgroud_Color]; | |
[[UINavigationBar appearance] setTranslucent:NO]; | |
// Bar item Color | |
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; | |
// 返回按钮图像 | |
[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"nav_back"]]; | |
// push 和pop 转换时的图像 | |
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"nav_back"]]; | |
} else { // iOS 6 | |
// 导航栏 背景颜色 | |
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; | |
[[UINavigationBar appearance] setBackgroundColor:Button_Backgroud_Color]; | |
} | |
// 导航栏 titile 字体 | |
NSDictionary *textAttributes = nil; | |
if ([[[UIDevice currentDevice] systemVersion] integerValue] >= 7.0) { | |
textAttributes = @{ | |
NSFontAttributeName: [UIFont boldSystemFontOfSize:20], | |
NSForegroundColorAttributeName: [UIColor whiteColor], | |
}; | |
} else { | |
textAttributes = @{ | |
UITextAttributeFont: [UIFont boldSystemFontOfSize:20], | |
UITextAttributeTextColor: [UIColor whiteColor], | |
UITextAttributeTextShadowColor: [UIColor clearColor], | |
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetZero], | |
}; | |
} | |
[[UINavigationBar appearance] setTitleTextAttributes:textAttributes]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment