【发布时间】:2014-08-31 16:37:58
【问题描述】:
注意,我最近又回到了这个问题,它似乎已在更新版本的 SDK 中得到修复,除了问题中的代码之外,我无需实现任何东西。非常感谢所有回答的人。
我有一个在 iPad 上运行的 Objective-C 应用程序并显示一个视图控制器,其模态表示样式为 UIModalPresentationPageSheet:
UINavigationController *editorNavigationController = [[UINavigationController alloc] initWithRootViewController:editorViewController];
editorNavigationController.modalPresentationStyle = UIModalPresentationPageSheet;
[navigationController presentViewController:editorNavigationController animated:YES completion:nil];
当显示这个视图控制器时,导航栏中的按钮是紫色的,我认为这是从窗口的色调中提取出来的,这就是我想要的。
稍后我需要在顶部显示另一个视图控制器,它会填满整个窗口:
UINavigationController *previewNavigationController = [[UINavigationController alloc]initWithRootViewController:myPreviewViewController];
[owningViewController presentViewController:previewNavigationController animated:YES completion:nil];
我的问题是当显示myPreviewController 时,导航栏中的按钮是灰色的。我尝试恢复新导航控制器的颜色:
previewNavigationController.navigationBar.tintColor = [UIColor colorWithRed:123/255.0 green:26/255.0 blue:69/255.0 alpha:1];
但没有任何快乐。
如何使按钮具有正确的颜色?我可以让新的导航控制器自动选择窗口色调,还是必须明确设置?这与在使用UIModalPresentationPageSheet 的导航控制器的顶部显示第二个导航控制器有关吗?
非常感谢任何帮助!谢谢,
保罗
【问题讨论】:
-
有截图吗?也许……
-
尝试在
myPreviewViewController的viewDidLoad中设置self.navigationController.navigationBar.tintColor -
感谢@kambala,但不幸的是没有解决它。
-
你试过用ios的外观方法吗?喜欢:[[UINavigationBar 外观] setBarTintColor:[UIColor redColor]]; [[UINavigationBar 外观] setTintColor:[UIColor grayColor]];
-
感谢@Alexander,但这也没有解决问题。我尝试在应用程序委托中调用 setTintColor,并在展示新导航控制器之前立即调用,但仍然没有任何乐趣。
标签: ios objective-c ipad uinavigationcontroller