Search code examples
iosobjective-ciphone-privateapisnapchat

Snapchat update status bar iOS7 update


On the latest snapchat update, when you "swipe right for messages" the status bar turns from black to white in a sort of gradient fashion.

How are they doing this without using private API's, or are they using private API's?

What I've looked into:

At first glance, I thought they are just doing what everyone else does, (like rdio currently does) by screen capturing the whole screen, and then modifying/animating that screenshot.

But... you cant access or animate the UIImage from that screen captures method, so although you could move/crop that screenshot, you cannot change its look.

So... I tested it, and when the status bar is in that state (half black/half white), it is still LIVE as in its not a screenshot, and it responds to charging changes/signal changes etc, as far as I can tell this is impossible without using a private API.


Solution

  • This got me curious so I played with the app a bit and inspected the view hierarchy of the app using Spark Inspector on a jailbroken device and I found a few things.

    You are incorrect about them not using a screenshot. The status bar on the side you are navigating AWAY from is a snapshot and does not change. You can easily see this when a minute goes by, the new status bar for the view you are transitioning into will have changed because it is real but the old one will not because it is a snapshot. That makes the illusion easy to work out.

    Here is what is happening at a high level:

    1. When you begin the transition, the app takes a snapshot of the status bar(most likely it is actually taking a snapshot of the entire UIScreen and simply cropping the status bar out of it) in its current state and attaches a window containing that snapshot to the top of the view in the transition, anchored to the final transition position and masked by the "from" view controller's view. This window appears to have a windowLevel above UIWindowLevelStatusBar so it is able to cover the real status bar.

    2. Then, the "to" view controller takes over the actual status bar and changes it to the "light content" state. This presents the clever illusion that a single status bar changes color with the transition border, but the real status bar is actually always sitting below the snapshot window and would indeed be visible immediately when the transitions begins if it weren't for the snapshot window sitting on top of it.