I want to hide status bar in my iPhone app on a button press and I want to show it again on pressing another button.
I tried to hide the status bar by overriding -(BOOL)prefersStatusBarHidden
in my view controller but this also removes its view from the top.
So a jump is seen on removing this status bar. What I want to do is just to hide the content on the status bar while keeping the background of status bar.
For example: You can check the same functionality in gmail app. When you open the side drawer in gmail app, then only the contents on status bar are hidden and there is no jump.
I fixed this problem with additionalSafeAreaInsets
property at iOS13. No other solution worked for me at iOS13.
When hiding status var set additionalSafeAreaInsets
top value to 20
, when unhiding set it again to 0
.
For devices with notch no need to change safe area insets. Do this for only other devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With