我正在尝试更改iOS 7中后退按钮的色调.现在有没有办法将整个应用程序中的所有导航项目更改为特定颜色?这就是我现在在一个视图控制器中所拥有的:
self.editButtonItem.tintColor = [UIColor whiteColor];
self.navigationItem.backBarButtonItem.tintColor = [UIColor whiteColor];
self.navigationController.navigationBarHidden = NO;
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;
self.title = @"Inbox";
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
Run Code Online (Sandbox Code Playgroud)
Gab*_*lla 30
UINavigationItem 不是视图,也没有颜色.
您想改变UIBarButtonItem色调颜色.
UIAppearance您可以使用代理
[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
Run Code Online (Sandbox Code Playgroud)
这将改变应用程序中tintColor的每个UIBarButtonItem.
您可以使用相同的策略来更改UINavigationBar barTintColor和titleTextAttributes:
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; // this will change the back button tint
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
Run Code Online (Sandbox Code Playgroud)
遗憾的是,无法translucent使用代理更改属性,因此您必须在每个栏上执行此操作.
| 归档时间: |
|
| 查看次数: |
16919 次 |
| 最近记录: |