ios – 导航栏上的按钮不会拾取窗口色调

注意,我最近回到这里,它似乎已经在更新版本的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的顶部的导航控制器有关吗?

任何帮助非常感谢!谢谢,

保罗

解决方法

您可以将navigationBar设置为半透明且透明.
在视图中将出现:
self.navigationController.navigationBar.translucent = NO;

然后创建一个框架大小为navigationBar的UIView(CGRectMake(0,self.view.frame.size.height,22),并在其上创建所需颜色的按钮.我知道,那是一个拐杖,但应该工作)

以上是来客网为你收集整理的ios – 导航栏上的按钮不会拾取窗口色调全部内容,希望文章能够帮你解决ios – 导航栏上的按钮不会拾取窗口色调所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。