现在,我必须在每次推送视图之前执行以下操作
_homeNavigationController.navigationBar.barStyle = UIBarStyleBlack;
_homeNavigationController.navigationBar.tintColor = nil;
我想使用带图案的图像将颜色设置为不同的颜色。
那么有没有简单的方法呢?
现在,我必须在每次推送视图之前执行以下操作
_homeNavigationController.navigationBar.barStyle = UIBarStyleBlack;
_homeNavigationController.navigationBar.tintColor = nil;
我想使用带图案的图像将颜色设置为不同的颜色。
那么有没有简单的方法呢?
如果您使用的是 iOS 5,则可以使用外观协议。
[[UINavigationBar appearance] setBackgroundImage:myImage];
文档可以在这里找到:
如果您想使用自定义色调(内置常量除外),请使用以下代码:
在全球某处定义这些。
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define COLOR_NAVBAR_TINT RGBCOLOR(82, 154, 217)
#define COLOR_TOOLBAR_TINT RGBCOLOR(82, 154, 217)
将此添加到您的 AppDelegate.m,然后在您的应用程序初始化期间调用它:
- (void)initializeGlobalTheme {
[[UINavigationBar appearance] setTintColor:COLOR_NAVBAR_TINT];
[[UIToolbar appearance] setTintColor:COLOR_TOOLBAR_TINT];
}