如何更改UIImagePickerController视图的UIStatusBarStyle文本颜色

时间:2017-07-10 00:28:31

标签: ios swift uistatusbar

尝试更改UIStatusBarStyle文字颜色的UIImagePickerController。尝试以下方法:

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

This回答显示即使是运营商徽标和UIStatusBarStyle也会按照指定更改颜色。但它并没有改变。是否还有其他事情可以尝试在UIStatusBarStyle中更改UIImagePicker文字颜色?

尝试使用以下代码,该代码适用于其他UIViewController s

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

但不工作..请帮忙。谢谢。

2 个答案:

答案 0 :(得分:4)

这是我的代码 - UIImagePIckerController的一个简单子类。

public class ImagePickerController: UIImagePickerController {

    override public func viewDidLoad() {
        super.viewDidLoad()
    }

    override public func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    override public var preferredStatusBarStyle : UIStatusBarStyle {
        return .lightContent
    }
}

答案 1 :(得分:0)

=======  将UINavigationControllerDelegate,UIImagePickerControllerDelegate添加到您的

@interface yourController()<>

=======

imagePickerController.delegate = self;

=======

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

==