Change NavigationBar background on UIDocumentInter

2019-08-14 19:20发布

I have to pass a local PDF file (documents directory) from UIWebView to other apps (iBooks, Facebook Messenger, WhatsApp, ...).

So i use UIDocumentInteractionController:

- (IBAction)shareButton:(id)sender
{
    NSURL *url = [NSURL URLWithString:self.webView.request.URL.absoluteString];

    self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
    self.docController.delegate = self;
    [self.docController presentOpenInMenuFromBarButtonItem:sender animated:YES];
}

If i select FB Messenger or WhatsApp it shows a ViewController.

How can i change the NavigationBar appearance of this VC (background image/color, button tint)? Default white translucent would be nice.

I set a NavigationBar background image in AppDelegate.

2条回答
戒情不戒烟
2楼-- · 2019-08-14 19:59

if you use this line then Just remove this line and everything works well.

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

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;
} 

It may be helpful to you

查看更多
Viruses.
3楼-- · 2019-08-14 20:01

Try this code:

- (void)openEC:(NSURL*)url {  
[UINavigationBar appearance].tintColor = [UIColor blueColor];  
docController = [UIDocumentInteractionController interactionControllerWithURL:url];  
[docController setDelegate:self];  
[docController  presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];  

}

- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller {  
[UINavigationBar appearance].tintColor = [UIColor whiteColor];  

}

查看更多
登录 后发表回答