DocumentInteractionController Navigation Bar Color

蹲街弑〆低调 提交于 2019-12-11 03:06:29

问题


In my iOS application, I am using the DocumentInteractionController to preview the .csv document.

    self.documentController = [UIDocumentInteractionController interactionControllerWithURL:fileLocation];
    [self.documentController setDelegate:self];
    [self.documentController presentPreviewAnimated:YES];

However, I am finding that the navigation bar is completely transparent. The back button is white, so it is not visible due to the white background.

Note that I have styled the navigation bar in the 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];

Essentially, my question is how can I make the appearance of the navigation bar in the DocumentInteractionController View Controller consistent with the appearance of the navigation bar throughout the entire app (or at least visible!).


回答1:


This line puts a transparent (or rather void) background image to your UINavigationBar. Why is that?

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];

Just remove the line and everything works well.

If you want to set a shadow image, then you should think about using appearanceWhenContainedIn: instead of appearance so it won't spread to unhandled controllers.

As for the Status Bar Style, the simplest way would be to pass self.navigationController as the presenter, instead of self:

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
  return self.navigationController;
}

Hope this will help,



来源:https://stackoverflow.com/questions/25083859/documentinteractioncontroller-navigation-bar-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!