내 앱에서 이미지를 내 ViewController's
. 프로젝트 설정의 상태 표시 줄에 대해 설정 : Status Bar Style - Default
. 상태 표시 줄에 다른 것을 사용하지 않습니다.
문제는 iOS 다크 모드가 활성화 status bar
되면 흰색이된다는 것입니다. 그리고 나는 그것을 검은 색으로 유지해야합니다. 그것을 고치는 방법?
또한 앱에서 지원하는 iOS 어두운 / 밝은 모드를 끄고 싶지 않습니다. 그래서 Appearance Light 는 Info.plist
저에게 적합하지 않습니다.
상태 표시 줄 스타일을 어두운 콘텐츠로 설정합니다.
그 후 info.plist 보기 컨트롤러 기반 상태 표시 줄 모양을 추가 하고 NO로 설정하십시오.
최신 정보
결정 컨트롤러에서만 어두운 내용을 원하면 viewWillAppear에서 setNeedsStatusBarAppearanceUpdate를 추가하고 그 후에 preferredStatusBarStyle을 재정의합니다.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setNeedsStatusBarAppearanceUpdate()
}
override var preferredStatusBarStyle: UIStatusBarStyle {
if #available(iOS 13.0, *) {
return .darkContent
} else {
return .default
}
탐색 컨트롤러로 시작 :
씬 델리게이트에서 첫 번째 탐색 컨트롤러를 선언합니다.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.makeKeyAndVisible()
let controller = UINavigationController(rootViewController: FirstViewController())
controller.navigationBar.barStyle = .black
window?.rootViewController = controller
}
SecondViewController에서 상태 표시 줄 스타일을 재정의합니다.
override var preferredStatusBarStyle: UIStatusBarStyle {
if #available(iOS 13.0, *) {
return .darkContent
} else {
return .default
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다