更改UIDocumentInteractionController上的导航栏背景

人气:490 发布:2022-10-16 标签: ios objective-c uinavigationbar

问题描述

我必须将本地PDF文件(文档目录)从UIWebView传递到其他应用(iBooks、Facebook Messenger、WhatsApp等)。

所以我使用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];
}

如果我选择FB Messenger或WhatsApp,它会显示一个ViewController。

如何更改此VC的导航栏外观(背景图像/颜色、按钮色调)?默认白色半透明效果更好。

我在AppDelegate中设置了导航栏背景图像。

推荐答案

尝试此代码:

- (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];  

}

340