2011-07-28 211 views

回答

3

如果您将UIDocumentInteractionController放到UINavigationController上,它会自动将其颜色作为其导航栏。这可能是您的根视图navcontroller。

你这样做与documentInteractionControllerViewControllerForPreview方法:

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller 
{ 
    // Use the rootViewController here so that the preview is pushed onto the navbar stack 
    MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    return appDelegate.window.rootViewController; 
} 
2

[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:107.0/256.0 green:145.0/256.0 blue:35.0/256.0 alpha:1.0]];

放置在AppDelegate中的didFinisLaunching方法的代码。它会改变整个应用程序导航栏的颜色。

+0

这将改变整个应用程序 –

10

一个清洁的版本@DOOManics实现:

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller 
{ 
    return [self navigationController]; 
} 
+0

巨大答案的颜色.. –

0

如果你不使用navigationController,你可以通过在这里的UIViewController的视图设置正确的设置,设置在UIDocumentInteractionController导航栏颜色你从中启动UIDocumentInteractionController。

比方说,你有UIViewController的viewController1(从这里你启动UIDocumentInteractionController),与故事板中的View1。

打开Storyboard后,单击viewController1上元素列表中的View1,然后转到右侧的“属性检查器”。这里设置的Background和Tint将会在你的UIDocumentInteractionController中使用。

然后,你可以使用:

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

注意,viewController1里面,你可能有一个导航栏具有不同的属性,它们不会在UIDocumentInteractionController使用。

+0

似乎并没有为工作我在ios7上。我按照上述说明改变了色调和背景颜色,但预览视图控制器的按钮保持蓝色。 – kritzikratzi

1

试试这个代码:

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

}