Skip to content

Instantly share code, notes, and snippets.

@xuyunan
Created January 29, 2013 03:54
Show Gist options
  • Save xuyunan/4661667 to your computer and use it in GitHub Desktop.
Save xuyunan/4661667 to your computer and use it in GitHub Desktop.
iOS5以上修改导航条上字体颜色
NSMutableDictionary *titleBarAttributes = [NSMutableDictionary dictionaryWithDictionary: [[UINavigationBar appearance] titleTextAttributes]];
[titleBarAttributes setValue:navBarTitleColor forKey:UITextAttributeTextColor];
[titleBarAttributes setValue:[NSValue valueWithUIOffset:UIOffsetMake(0.f, 0.f)] forKey:UITextAttributeTextShadowOffset];
[[UINavigationBar appearance] setTitleTextAttributes:titleBarAttributes];
[[UINavigationBar appearance] setBackgroundColor:[UIColor clearColor]];
[[UINavigationBar appearance] setTintColor:kNAVIGATIONBAR_BARBUTTON_COLOR];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor],
UITextAttributeTextColor,
[UIColor clearColor],
UITextAttributeTextShadowColor, nil];
[[UIBarButtonItem appearance] setTitleTextAttributes: attributes
forState: UIControlStateNormal];
NSDictionary *highlightedAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor],
UITextAttributeTextColor,
[UIColor clearColor],
UITextAttributeTextShadowColor, nil];
[[UIBarButtonItem appearance] setTitleTextAttributes: highlightedAttributes
forState: UIControlStateHighlighted];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment