如何更改完成按钮的背景颜色和文本颜色?有没有办法可以更改导航栏颜色和导航栏标题颜色和底栏颜色?参考附截图: 如何更改UIDocumentInteractionController完成按钮的文本和背景颜色
回答
我有一个IDEAR改变栏的颜色:
let allNavigationBar = UINavigationBar.appearance()
allNavigationBar.barTintColor = UIColor.red // change the bar background color
allNavigationBar.tintColor = UIColor.black // change the Done button's tintColor
let alloolbar = UIToolbar.appearance()
allToolbar.barTintColor = UIColor.red // dones't work, try backgroundImage
allToolbar.backgroundColor = UIColor.blue // dones't work
allToolbar.tintColor = UIColor.brown // change the toolbar's item tint color
但这种方法有很大的作用,所有的UINavigationBar
和UIToolBar
将做出的改变。
希望其他人能给出更好的选择。
您可以暂时更改窗口的色调颜色。
func presentDocument() {
//present the controller here
self.appDelegate.window.tintColor = UIColor.red
}
再改回来以后:
func documentInteractionControllerDidEndPreview(documentInteractionController) { //replace parameter with your uidocumentviewinteractioncontroller
self.appDelegate.window.tintColor = UIColor.white
}
@Dee。我想你已经在你的其他问题之一中问过这个部分了。在这种情况下,您无法显示预览控制器。在这个问题中,建议的答案是从该委托方法返回“自我”。如果您正确实现了该功能,则预览将使用与其父控制器所使用的颜色相同的导航栏颜色。我的意思是如果你已经直接从一些ViewController打开UIDocumentInteractionController,那么UIDocumentInteractionController将使用它的父级viewController的导航栏颜色。这可能会帮助你改变完成按钮的颜色
我现在可以修改导航栏按钮标题,文本和背景颜色。但底部的工具栏颜色不起作用。您能否帮我解决这个问题 – Dee
@Dee我无法修改导航栏按钮的标题,文字和背景颜色。你是怎么做到的? –
我解决了它。这里是为我工作的代码完美:
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
UINavigationBar.appearance().barTintColor = Colors.redColor()
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont.systemFont(ofSize: 14, weight: UIFontWeightBold)]
return self
}
let QLNavAppearance = UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self])
QLNavAppearance.tintColor = UIColor.red // some
QLNavAppearance.barTintColor = UIColor.red // some
QLNavAppearance.backgroundColor = UIColor.red // some
这是一个有点哈克为依托的事实,QLPreviewController是实施UIDocumentInteractionController类,但这样的事情是侵入性最小的解决方案。在显示UIDocumentInteractionController之前执行此操作
import QuickLook
UIBarButtonItem.appearance(whenContainedInInstancesOf [QLPreviewController.self]).tintColor = UIColor.black
- 1. 编辑/完成按钮,更改完成按钮背景颜色
- 2. 更改完成后命令按钮的值和背景颜色
- 3. 更改按钮的背景颜色
- 4. 更改按钮颜色作为背景颜色更改?
- 5. 使用按钮更改标签背景和按钮文本颜色
- 6. 如何动态更改按下按钮的背景颜色?
- 7. 更改UIWebView完成按钮颜色
- 8. 更改文本框的背景颜色
- 9. 更改文本框的背景颜色
- 10. 如何更改Android上的切换按钮的背景颜色
- 11. 如何更改按钮和背景之间的按钮背景?
- 12. 如何以编程方式更改按钮的背景颜色
- 13. 如何更改按钮中的背景颜色大小?
- 14. 如何更改c中的按钮背景颜色#
- 15. 如何更改按钮的背景颜色
- 16. 如何用jquery更改按钮的背景颜色onmouseover?
- 17. 如何更改ListView中的文本颜色和背景?
- 18. 如何更改notifyIcon组件的背景颜色和文本
- 19. 文本视图,更改背景颜色
- 20. 如何更改每个帖子下的按钮背景和文字颜色
- 21. Android WebView更改HTML按钮点击的背景和文本颜色
- 22. 如何更改Notepad ++背景颜色以更改文本行?
- 23. 按下/下按钮时,如何更改按钮的背景颜色?
- 24. 更改变焦按钮的背景颜色和形状,AChartEngine
- 25. 如何更改UIAction表取消按钮背景颜色
- 26. Eclipse如何将按钮背景颜色更改为默认值
- 27. 设置背景颜色改变按钮
- 28. 如何更改微调器文本和背景颜色?
- 29. UWP Template10 - 更改主题时更改按钮背景颜色
- 30. hotcocoa按钮背景颜色
屏幕截图 – paper1111
我可以看到附加的屏幕截图。它不可见吗?我需要再次上传吗? – Dee
我现在可以看到它,现在它说'imgur已超过容量' – paper1111