问题
I have a view controller that needs to hide the status bar before presenting a modal and after that modal is dismissed.
This is not as simple as overriding prefersStatusBarHidden
and then setting modalPresentationCapturesStatusBarAppearance
because that will also cause a jump given I am presenting over the current context (the modal is a pull down to dismiss).
Consider the instagram story UX, as an example. When tapping on a story, you actually see the status bar disappear before the story modal is presented. Then when pulling the story down to dismiss it, the modal view controller actually must be completely dismissed before they redisplay the status bar.
I originally implemented a custom status bar that would do a lot of tricks to maintain the proper size and position given the device / iOS combos (iOS 10 & 11 + iPhone X and non iPhone X) but that was proving to be very painful unless I detected the device and hardcoded the safe area / layout guide dimensions. So currently I am attempting to do this with the stock UINavigationBar.
Any idea how this is possible?
来源:https://stackoverflow.com/questions/50771879/how-do-i-hide-the-status-bar-in-an-ios-app-without-causing-the-uinavigationbar-t