Search code examples
iosswiftuistatusbar

How to change UIStatusBarStyle text color of a UIImagePickerController view


Trying to change UIStatusBarStyle of UIImagePickerController text color. Tried the following:

imagePicker.navigationBar.isTranslucent = false
imagePicker.navigationBar.barTintColor = .darkGray
imagePicker.navigationBar.tintColor = .white
imagePicker.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]

This answer displays that even the carrier logo and UIStatusBarStyle also changes it color as specified. But it is not changing. Is there any other thing that could be tried to make the UIStatusBarStyle text color change in the UIImagePicker?

Tried the following code which is working for other UIViewControllers

imagePicker.preferredStatusBarStyle = UIStatusBarStyle.lightContent
imagePicker.setNeedsStatusBarAppearanceUpdate()

But not working.. Please help. Thank you.


Solution

  • Here's my code - a simple subclass of UIImagePIckerController.

    public class ImagePickerController: UIImagePickerController {
    
        override public func viewDidLoad() {
            super.viewDidLoad()
        }
    
        override public func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
        }
    
        override public var preferredStatusBarStyle : UIStatusBarStyle {
            return .lightContent
        }
    }