How to make UIImagePickerController StatusBar lightContent style?

前端 未结 7 1623
悲哀的现实
悲哀的现实 2020-12-29 12:53

\"enter

When I present the ImagePickerController the statusBar text color is still bla

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 13:29

    I was facing a similar problem and I found the cleanest way to solve it was to override preferredStatusBarStyle in an extension of UIImagePickerController like so. This principal can be applied to third party libraries nicely.

    extension UIImagePickerController {
        open override var preferredStatusBarStyle: UIStatusBarStyle {
            if isLightTheme() {
                return .default // black text
            }
            return .lightContent // white text
        }
    }
    

    isLightTheme() is simply a function to determine whether the NavigationBar in that controller is a light or dark colour.

提交回复
热议问题