更改“更多”部分的“编辑”屏幕上的导航栏颜色

发布于 2024-09-10 23:37:55 字数 271 浏览 3 评论 0原文

我可以通过以下方式更改“更多”导航控制器的导航栏颜色:

stTabBarController.moreNavigationController.navigationBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];

但是当我单击“编辑”按钮时,会出现“配置”屏幕,并且导航栏颜色为默认蓝色。我怎样才能改变这个颜色?

I am able to change the navbar color of the More navigationcontroller via:

stTabBarController.moreNavigationController.navigationBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];

but when I click the Edit button, the Configure screen appears and the navbar color is the default blue. How can I change this color?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沫雨熙 2024-09-17 23:37:55

解决了:

#pragma mark UITabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)controller willBeginCustomizingViewControllers:(NSArray *)viewControllers {
    UIView *editViews = [controller.view.subviews objectAtIndex:1];
    UINavigationBar *editModalNavBar = [editViews.subviews objectAtIndex:0];

    editModalNavBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];

}

Solved it:

#pragma mark UITabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)controller willBeginCustomizingViewControllers:(NSArray *)viewControllers {
    UIView *editViews = [controller.view.subviews objectAtIndex:1];
    UINavigationBar *editModalNavBar = [editViews.subviews objectAtIndex:0];

    editModalNavBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];

}
往日 2024-09-17 23:37:55

对于有这个问题的其他人,为了让 Sheehan Alam 的解决方案发挥作用,您需要确保在 viewDidLoad 方法中将 tabBarController 的委托设置为 self,如下所示:

- (void)viewDidLoad {
  ...
  self.delegate = self;
  ...
}

然后您需要确保您的 tabBarController 符合 UITabBarControllerDelegate 协议,如下所示:

@interface TabBarController : UITabBarController <UITabBarControllerDelegate> {
  ...
} 

否则他重写的方法将不会被调用。

To anyone else with this question, in order for Sheehan Alam's solution to work, you need to make sure you set the tabBarController's delegate to self within the viewDidLoad method like so:

- (void)viewDidLoad {
  ...
  self.delegate = self;
  ...
}

Then you need to make sure your tabBarController conforms to the UITabBarControllerDelegate protocol like so:

@interface TabBarController : UITabBarController <UITabBarControllerDelegate> {
  ...
} 

Otherwise the method he's overriding won't be called.

陌生 2024-09-17 23:37:55

@Sheehan Alam 解决方案对我不起作用(在 iOS 8 上工作)。无论如何,我从他的回答中得到了 2/3 的答案。我发布此内容是为了改进答案。

#prama mark - UITabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers {

   UIView *editViews = [tabBarController.view.subviews objectAtIndex:1];

   for (UIView * view in [editViews subviews]) {
       if ([view isKindOfClass:[UINavigationBar class]]) {
           UINavigationBar *editNavBar = (UINavigationBar *)view;
           editNavBar.barTintColor = [UIColor redColor];
       }
   }
}

@Sheehan Alam solution did not work for me (working on iOS 8). Anyway I got 2/3 of the solution from his answers. I am posting this to improve the answer.

#prama mark - UITabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers {

   UIView *editViews = [tabBarController.view.subviews objectAtIndex:1];

   for (UIView * view in [editViews subviews]) {
       if ([view isKindOfClass:[UINavigationBar class]]) {
           UINavigationBar *editNavBar = (UINavigationBar *)view;
           editNavBar.barTintColor = [UIColor redColor];
       }
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文