为什么tintColor在iOS7上的导航栏或工具栏上不起作用

 手机用户2502903077 发布于 2023-02-06 10:00

在iPad的iOS7上,首先,我设置了一个模态视图控制器,大小为320*460,然后,在这个模态视图控制器中,我提出了另一个导航视图控制器,在此之后,导航栏和工具栏的色调颜色呈现的导航控制器变灰.我试图设置导航栏和工具栏的色调,但它不起作用.

然后我尝试直接呈现导航控制器,然后所有色调颜色都在导航栏和工具栏上工作.

我试过barTintColor导航栏和工具栏的属性,它的工作原理.

我不知道会发生什么.

更新

首先,我定义一个视图控制器:modalViewController现在的模态视图控制器如下:

if (DeviceIsPad()) // DeviceIsPad is a method defined somewhere to tell that the device is an iPad.
    modaViewController.modalPresentationStyle = UIModalPresentationFormSheet;

//here self is a normal view controller
[self presentViewController:modalViewController animated:YES completion:NULL];

其次,定义导航视图控制器:navigationController如下所示呈现导航控制器:

if (DeviceIsPad())
    navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;

// here self means the modalViewController mentioned above
[self presentViewController:navigationController animated:YES completion:nil];

我在navigationController的'viewDidLoad'方法中设置导航栏和工具栏栏项.

默认情况下,当导航视图控制器出来的时候,所有的工具栏按钮的项目(这些项目是与像只是基本的标题建Cancel,OK)变成灰色.

与此同时,我已经尝试设置tintColortool barnavigation bar.使用实例方法和外观方法(如[[UIToolBar appearance] setTintColor:[UIColor blueColor]]).但它仍然无效.

然后我尝试直接从普通视图控制器呈现navigationViewController上面提到的UIModalPresentationFormSheet样式,然后导航栏和工具栏的所有tintColor变成蓝色(系统蓝色).

1 个回答
  • 发生这种情况是因为Apple假定我们不会提供多于一个视图控制器并将背景和所有条形按钮项目(不确定原因)调暗为默认行为以将焦点放在最前面的视图上.

    要解决此问题,您只需要在DidFinishLaunchingWithOptions的应用程序窗口中强制tintAdjustmentMode为Normal.

    self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
    

    2023-02-06 10:03 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有