在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
)变成灰色.
与此同时,我已经尝试设置tintColor
的tool bar
和navigation bar
.使用实例方法和外观方法(如[[UIToolBar appearance] setTintColor:[UIColor blueColor]]
).但它仍然无效.
然后我尝试直接从普通视图控制器呈现navigationViewController
上面提到的UIModalPresentationFormSheet
样式,然后导航栏和工具栏的所有tintColor变成蓝色(系统蓝色).
发生这种情况是因为Apple假定我们不会提供多于一个视图控制器并将背景和所有条形按钮项目(不确定原因)调暗为默认行为以将焦点放在最前面的视图上.
要解决此问题,您只需要在DidFinishLaunchingWithOptions的应用程序窗口中强制tintAdjustmentMode为Normal.
self.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;