我想改变UINavigationBar
titleColor
.
我也想改textColor
的UINavigationBar
backButton
。
我正在使用 iPhone Os sdk 3.1.2
我想改变UINavigationBar
titleColor
.
我也想改textColor
的UINavigationBar
backButton
。
我正在使用 iPhone Os sdk 3.1.2
这对我有用。
使用它,您可以更改所有导航按钮的颜色:
[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];
将 redColor 替换为以下内容以调整按钮的颜色:
colorWithRed:0/255.0 green:144/255.0 blue:200/255.0 alpha:1.0// pick your color using this
一定要把它放在推送的视图控制器中。不是您想要查看此后退按钮颜色的视图控制器。
这个问题的一部分已经得到了回答。
然后,要更改后退按钮标题颜色,我建议创建一个带有标签的自定义按钮:
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:yourViewWithColoredText];
navigationItem.leftBarButtonItem = buttonItem; // assign it as the left button
yourViewWithColoredText
应该是包含彩色文本的自定义视图。然后根据你的需要,你可以让它看起来像一个标准的后退按钮。
您可以将 UINavigationBar.h 中定义的 titleView 设置为:
@property(nonatomic,retain) UIView *titleView;
// Custom view to use in lieu of a title. May be sized horizontally. Only used when item is topmost on the stack.
用你想要的任何颜色弹出你自己的 UILabel。
UIBarButtonItem *button = [[UIBarButtonItem alloc] init];
[button setTintColor:[UIColor redColor]];
在 iOS 5 和 6 上设置为title
开启UINavigationBar
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:UITextAttributeTextColor]];
在 iOS 7 上
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor]};
textColor
全部设置UIBarButtonItem
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor], UITextAttributeTextColor,
[UIColor clearColor], UITextAttributeTextShadowColor, nil];
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState: UIControlStateNormal];