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

Pau*_*aul 5 objective-c uinavigationcontroller ipad ios

注意,我最近回到这里,它似乎已经在更新版本的SDK中得到修复,除了问题中的代码之外我不需要实现任何东西.非常感谢所有回答的人.

我有一个在iPad上运行的Objective-C应用程序,并显示一个视图控制器,其模式演示风格为UIModalPresentationPageSheet:

UINavigationController *editorNavigationController = [[UINavigationController alloc] initWithRootViewController:editorViewController];
editorNavigationController.modalPresentationStyle = UIModalPresentationPageSheet;
[navigationController presentViewController:editorNavigationController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

当显示这个视图控制器时,导航栏中的按钮是紫色的,我假设它是从窗口的色调中拾取的,这就是我想要的.

后来我需要在顶部显示另一个视图控制器,它填满了整个窗口:

UINavigationController *previewNavigationController = [[UINavigationController alloc]initWithRootViewController:myPreviewViewController];
[owningViewController presentViewController:previewNavigationController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是,当myPreviewController显示时,导航栏中的按钮是灰色的.我尝试在新的导航控制器上恢复颜色:

previewNavigationController.navigationBar.tintColor = [UIColor colorWithRed:123/255.0 green:26/255.0 blue:69/255.0 alpha:1];
Run Code Online (Sandbox Code Playgroud)

但没有任何快乐.

如何让按钮具有正确的颜色?我可以让新的导航控制器自动拾取窗口色调颜色,还是必须明确设置它?这与将第二个导航控制器显示在使用的第二个导航控制器的顶部有关UIModalPresentationPageSheet吗?

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

保罗

Nik*_*Kov 2

可以设置navigationBar半透明和透明。视图中Will Appear

self.navigationController.navigationBar.translucent = NO;
Run Code Online (Sandbox Code Playgroud)

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