How to change AVMediaSelectionViewController's Done Button Font Color?

We are playing video in an AVPlayerViewController. The video contains subtitles, and when the user enters the AVMediaSelectionViewController in order to select a subtitle language, the Done button is completely invisible because it is a white font on a white background.


Does anyone know of a way to change the font color on this button?

Replies

Cannot find a reference to AVPlayerViewController class.

Hi

Were you able to find answer to this question? I have tried numerous things including UINavigationBar appearance, extending UINavigationController none of which unfortunately work.

Let me know if you were able to find a solution.
Hi @seanmp

I was able to update the navigation bar if the AVMediaSelectionTableViewController using an extension class of UINavigationController. Please see code used below:

Code Block
open override func viewDidLayoutSubviews() {
let subtitleViewController: AnyClass? = NSClassFromString("AVMediaSelectionTableViewController")
for childVC in self.viewControllers {
if let subtitleViewController = subtitleViewController, childVC.isKind(of: subtitleViewController) {
var normalTitleTextAttributes = childVC.navigationItem.rightBarButtonItem?.titleTextAttributes(for: .normal)
var highlightedTitleTextAttributes = childVC.navigationItem.rightBarButtonItem?.titleTextAttributes(for: .highlighted)
var disabledTitleTextAttributes = childVC.navigationItem.rightBarButtonItem?.titleTextAttributes(for: .disabled)
normalTitleTextAttributes?[NSAttributedString.Key.foregroundColor] = UIColor.black
highlightedTitleTextAttributes?[NSAttributedString.Key.foregroundColor] = UIColor.black
disabledTitleTextAttributes?[NSAttributedString.Key.foregroundColor] = UIColor.black
childVC.navigationItem.rightBarButtonItem?.setTitleTextAttributes(normalTitleTextAttributes, for: .normal)
childVC.navigationItem.rightBarButtonItem?.setTitleTextAttributes(highlightedTitleTextAttributes, for: .highlighted)
childVC.navigationItem.rightBarButtonItem?.setTitleTextAttributes(disabledTitleTextAttributes, for: .disabled)
break
}
}
}

This will work. It will change the done button color

UIBarButtonItem.appearance().tintColor = .green