我正在尝试使用QLPreviewController查看PDF,并且正在努力更改一些视图属性,例如导航栏、标题和视图的背景。
在对QLPreviewController进行子类化并在didViewAppear方法中更改self.navigationController.navigationBar.translucency = NO;之后,我能够更改导航栏的半透明度,但是我无法更改self.view.backgroundColor的navigationBar.title或backgroundColor属性。
当视图第一次加载时,标题和背景颜色都会闪烁,但会立即被PDF标题字符串和PDF本身取代,这会覆盖视图的背景颜色。PDF页面显示在黑色背景上。
我首先想知道是否有可能将背景颜色子类化或以其他方式更改为我自己的自定义颜色,然后我想知道是否有人有任何建议或知道一个像样的解决方案来更改背景颜色。
标题值在较小程度上也是如此。
发布于 2017-12-08 20:48:41
在Swift 4的子类UINavigationController中放入:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).isTranslucent = false
UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).tintColor = #colorLiteral(red: 0.1889409125, green: 0.6918108463, blue: 0.9730117917, alpha: 1)
UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
}https://stackoverflow.com/questions/28200678
复制相似问题