Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving status bar in iOS 7

The problem I'm facing is this:

I want to implement an iOS 7 app with nice design and left/right menu, which appears after the main view animate itself to the right/left. I'm doing this with [UIView animateWithDuration...] code, but that's not really important. What I want to achieve is the same effect the Mailbox iOS 7 app has: to move the status bar away (to the right/left) with the main view

Image for better explanation:

Mailbox app with status bar moved to the side

What I only found is this article about the issue, with some working code using Private APIs, which I'd like not to use, since I want my app to be accepted on the App Store.

I'd like to achieve the same effect ('legally'). Does anybody knows how to?

Thanks!

like image 209
Gyfis Avatar asked Sep 25 '13 14:09

Gyfis


People also ask

Can you customize Iphone status bar?

You can select from several preset Focuses, such as driving, working out, or reading, or you can set a custom Focus for something you often do. Within the settings it lets you add an identification icon that will appear in the status bar while in use. The trick is you don't actually have to set anything to turn off.

How can I add status bar in iOS?

@learner Goto info. plist and then select any row. You will see a + sign. Click on Plus sign and from drop down, you should see Status bar style Option.

What is status bar height in iOS?

By default Status Bar height in iOS is 20 pt .


1 Answers

The gist of it is to use this method introduced in iOS 7:

https://developer.apple.com/documentation/uikit/uiscreen/1617814-snapshotview:

With that you get a UIView containing a screenshot that includes the status bar. Once you have that, it's just a matter of hiding your current view then pushing the screenshot view around.

I posted a proof of concept here: https://github.com/simonholroyd/StatusBarTest

NOTE I haven't submitted code that does this through the Apple review process, but this is not a private API method.

like image 131
Simon Holroyd Avatar answered Sep 18 '22 20:09

Simon Holroyd