ios - Hide status bar but not custom UIWindow -
i have custom uiwindow own status bar, want hide status bar , show mine instead. have
override var prefersstatusbarhidden: bool { return true }
in both uiwindow's rootviewcontroller , main viewcontroller. hides status bar, hides uiwindow. uiwindow's windowlevel
uiwindowlevelstatusbar + 1
, tested other windowlevel
s , hidden regardless of level.
setting opaque background custom uiwindow not option.
how can hide status bar not custom uiwindow?
edit: better solution
the same still holds true before/below, actual code shorter, simpler, , more swifty.
in appdelegate, have
func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool { // override point customization after application launch. mystatusbarwindow.ishidden = false return true }
and, of course, hide system status bar. either in build settings or info.plist, or in view controller, say
override var prefersstatusbarhidden: bool { return true }
much better :)
old solution
unfortunately, cannot find best answer, have workaround:
first show window. after should hide status bar. not sure why works, does. can this:
// class var var statusbarhidden = false // example in viewdidload order matters override func viewdidload() { mywindow.ishidden = false statusbarhidden = true setneedsstatusbarappearanceupdate() } override var prefersstatusbarhidden: bool { return statusbarhidden }
through experimentation discovered prefersstatusbarhidden
checked before viewdidload
. thus, need tell view controller check again once window shown. again, don't know why works, does. if can explain phenomenon (why order matters), excellent supplement solution.
Comments
Post a Comment