有沒有辦法更改UIDocumentInteractionController導航欄的色調/背景顏色?更改UIDocumentInteractionController導航欄的顏色
回答
如果您將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;
}
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:107.0/256.0 green:145.0/256.0 blue:35.0/256.0 alpha:1.0]];
放置在AppDelegate中的didFinisLaunching
方法的代碼。它會改變整個應用程序導航欄的顏色。
一個清潔的版本@DOOManics實現:
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return [self navigationController];
}
巨大答案的顏色.. –
如果你不使用navigationController,你可以通過在這裏的UIViewController的視圖設置正確的設置,設置在UIDocumentInteractionController導航欄顏色你從中啓動UIDocumentInteractionController。
比方說,你有UIViewController的viewController1(從這裏你啓動UIDocumentInteractionController),與故事板中的View1。
打開Storyboard後,單擊viewController1上元素列表中的View1,然後轉到右側的「屬性檢查器」。這裏設置的Background和Tint將會在你的UIDocumentInteractionController中使用。
然後,你可以使用:
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
注意,viewController1裏面,你可能有一個導航欄具有不同的屬性,它們不會在UIDocumentInteractionController使用。
似乎並沒有爲工作我在ios7上。我按照上述說明改變了色調和背景顏色,但預覽視圖控制器的按鈕保持藍色。 – kritzikratzi
試試這個代碼:
- (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];
}
- 1. 更改導航欄的顏色
- 2. 更改UIActivityViewController的導航欄顏色
- 3. 更改摺疊的導航欄顏色
- 4. Swift - iOS:更改導航欄的顏色
- 5. 更改導航欄的按鈕顏色
- 6. 更改導航欄的顏色2.0.4
- 7. 更改導航欄的默認顏色
- 8. Xamarin.forms如何更改導航欄顏色
- 9. 灰度Bootstrap導航欄 - 更改顏色
- 10. 滾動時更改導航欄顏色
- 11. 更改導航欄背景顏色?
- 12. 更改導航欄文本顏色
- 13. Bootstrap-sass更改導航欄顏色
- 14. 在MFMailComposeViewController中更改導航欄顏色
- 15. iPad SplitView更改主導航欄顏色
- 16. 更改導航欄色調更改顏色不正確
- 17. 如何更改導航欄和導航文本顏色的背景顏色
- 18. 根據其位置更改導航欄顏色。顏色不變
- 19. 如何更改Liferay 6.2中的導航欄和導航欄的顏色
- 20. 如何更改導航欄上的導航欄鏈接輪廓顏色
- 21. 更改滾動條上的引導導航欄的顏色
- 22. 更改鏈接的顏色在我的引導導航欄
- 23. 更改導航欄的顏色(背景色)
- 24. 導航欄的HTML顏色
- 25. 無法更改引導程序3中導航欄的顏色?
- 26. 更改導航欄引導程序的文本顏色
- 27. 如何更改引導程序導航欄的顏色?
- 28. 以編程方式更改狀態欄顏色等於導航欄顏色
- 29. 更改顏色導航欄,選項卡欄
- 30. iOS狀態欄更改顏色以自行匹配導航欄
這將改變整個應用程序 –