Is it possible to have dynamically coloring statusBar
which is in the new Apple Music app ?
Edit:
The new Apple Music app in iOS 8.4 has this feature.
- Open the app.
- Select and play a song (status bar is white)
- Swipe player controller down to see "My music" controller (it has black status bar, maybe you will have to go back in navigation hierarchy).
- Now just swipe up/down to see dynamic status bar changes.
Edit 2:
Apple documentation does not seem to let us use it right now (iOS 8.4
). Will be available probably in the future with iOS 9
.
Edit 3:
Does not seems to be available in iOS 9
yet.
Thinking about how to implement this without private APIs.
I think there may be a solution with second UIWindow overlaying your statusBar.
Adding view on StatusBar in iPhone
Maybe it's possible to make screenshots of status bar constantly (taken from your main Window) to the image, apply some filter on it and display this 'fake statusbar image' on your second window (above 'real' statusBar).
And you can do what you want with the second "fake" statusbar.
Iterating upon Jiri's answer, this will get you pretty close. Substitute MTStatusBarOverlay with CWStatusBarNotification. To handle the modal transition between view controllers, I'm using MusicPlayerTransition. We're assuming an imageView: "art" in self.view with frame:CGRect(0, 0, self.view.bounds.size.width, self.view.bounds.size.width). Needs a little massaging, but you get the gist. Note: Though we're not "live," the most we'll ever be off is one second, and battery color is not preserved. Also, you'll need to set the animation time in CWStatusBarNotification.m to zero. (notificationAnimationDuration property).
}
To keep your status bar screenshots in sync with the actual status bar, setup your timer. Fire it in viewWillAppear, and kill it in viewDidDisappear.
Because we have a strong reference to the timer and setup and invalidation happens on the same thread, there's no worrying about the timer failing to invalidate. The final result should look something like this:
At first glance it looked like a manipulation of a snapshot from the status bar but the status bar is live on both ends so that's not the case.
At second glance it looked like some new api that was introduced in iOS 8.4 but after reviewing the api I couldn't find anything related to that.
It seems very odd to me that apple would use private apis in her own app. This would results some really bad example for developers but then again, there is nothing public that will let you have two styles on your live statusbar.
This leaves us with private api or black magic.
I am 99.99% sure this cannot be done using public API (easily), because I tried myself almost everything there is (i personally also don't think it is some magical method of their status bar, but instead, their application is able to retrieve status bar view and then just apply mask to it).
What I am sure of is that you can do your own StatusBar and there is MTStatusBarOverlay library for that, unfortunately very old one so I can't really tell if that works but it seems that there are still people who use it.
But using the way library does it, I think there might be solution that sure, requires a lot of work, but is doable, though not "live". In a nutshell you would do this:
Now you should be able to scroll properly and change the color properly. The only problem that it leaves is that status bar is not alive, but is it really? once you scroll out, you immediately remove your overlay, letting it to refresh. You will do the same when you scroll to the very top, but in that case, you change color of the status bar to white (no animation), so it fits your state. It will be not-live only for a brief period of time.
Hope it helps!