Search code examples
iosiphonexcodeswift3ios11

Change navigation bar color in QLPreviewController


I want to change navigation bar color of QLPreviewController in swift 3. I have used below code to change color but its not working

viewQLPreview = QLPreviewController()
viewQLPreview.dataSource = self
viewQLPreview.delegate = self
viewQLPreview.navigationController?.navigationBar.isTranslucent = false
viewQLPreview.navigationController?.navigationBar.tintColor = UIColor.red

Solution

  • I have used below code to Change navigation bar color of QLPreviewController in swift 3.0

    UINavigationBar.appearance().barTintColor = UIColor.red
    
    UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]).backgroundColor = UIColor.red