How to change UIDocumentInteractionController text color?

180 views Asked by At

My app has an option for a dark theme, and when that is the case, I do something like this:

    UILabel.appearance().textColor = .white

The problem is, the app provides the ability to export some text via UIDocumentInteractionController. When I do presentPreview it displays white text on a white background, which makes the text completely invisible. There doesn't seem to be any way to change the text color or background color of the UIDocumentInteractionController.

I tried this

UILabel.appearance(whenContainedInInstancesOf: [UIDocumentInteractionController.self]).textColor = .black

but that just gives Cannot convert value of type 'UIDocumentInteractionController.Type' to expected element type 'UIAppearanceContainer.Type'

I've also tried setting UILabel.appearance().textColor = .black before I create the UIDocumentInteractionController, but that doesn't help either - the text still appears white.

What's extra annoying, this works to change the nav bar title color:

let navBarTitleTextAttributes = [
      NSAttributedString.Key.foregroundColor: UIColor.black,
]
UINavigationBar.appearance().titleTextAttributes = navBarTitleTextAttributes
self.dic = UIDocumentInteractionController()
...

But the label appearance is not responsive.

0

There are 0 answers