Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
805 views
in Technique[技术] by (71.8m points)

objective c - Hide status bar in iOS without removing its view

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...