I've seen an app wherein they can dynamically adjust their status bar height/y-position based on scroll-position.
Here is a sample gif: https://gyazo.com/ec8e3fa336098305e6a5aedc68118789
Here is what I got
override var prefersStatusBarHidden: Bool {
return isStatusBarHidden
}
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
if !isStatusBarHidden {
return UIStatusBarAnimation.fade
} else {
return UIStatusBarAnimation.slide
}
}
func changeStatusBarStatus(status: Bool) {
isStatusBarHidden = status
UIView.animate(withDuration: 0.3, delay: 0, options: [.allowUserInteraction], animations: {
self.setNeedsStatusBarAppearanceUpdate()
})
}
TO CREATE CUSTOM StatusBar
Firstly Hide your Default statusBar
for the entire app by adding YES/TRUE in Status bar is initially hidden
in the info.plist
This will hide StatusBar
from the app unless you add programatically re-show it.
Then add a UIView
in your ViewController
and give it TOP, LEFT & RIGHT constraint
(0,0,0) with reference to View
(not with reference to Safe Area
)
Then Give it DOWN or BOTTOM constraint
0 with reference to your Main working UIView
See, I've created a bottom view like that in my app (You just have to reverse this constraint
as you are creating StatusBar
)
(Note:If you can't see that UIView
then use View As iPhone 10 or 11 Series in which you can clearly distinguish it from your other UIView
)