简体   繁体   中英

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 UIViewController s

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

But not working.. Please help. Thank you.

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
    }
}

======= Add UINavigationControllerDelegate,UIImagePickerControllerDelegate to your

@interface yourController ()<>

=======

imagePickerController.delegate = self;

=======

-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; }

======

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM