DocumentInteractionController导航栏颜色
在我的iOS应用程序中,我使用DocumentInteractionController来预览.csv文档。
self.documentController = [UIDocumentInteractionController interactionControllerWithURL:fileLocation]; [self.documentController setDelegate:self]; [self.documentController presentPreviewAnimated:YES];
但是,我发现导航栏是完全透明的。 后退按钮为白色,因此由于白色背景而不可见。
请注意,我已经在AppDelegate中设置了导航栏的样式:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0/255.0f green:138/255.0f blue:188/255.0f alpha:1.0f]]; [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"DINPro-Bold" size:17]}]; [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setShadowImage:[UIImage imageNamed:@"shadow"]]; [[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]]; [[UITabBar appearance] setTintColor:[UIColor whiteColor]]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
基本上,我的问题是如何使DocumentInteractionController视图控制器中导航栏的外观与整个应用程序中导航栏的外观一致(或至少可见!)。
此行将透明(或相当无效)的背景图像放入UINavigationBar。 这是为什么?
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
只需删除该行,一切正常。
如果你想设置一个阴影图像,那么你应该考虑使用appearanceWhenContainedIn:
而不是appearance
这样它就不会传播到未处理的控制器。
对于状态栏样式,最简单的方法是将self.navigationController
作为演示者而不是self:
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller { return self.navigationController; }
希望这会有所帮助,