与新的Apple Music应用程序中相同的动态状态栏 [英] The same dynamic status bar as is in the new Apple Music app

查看:118
本文介绍了与新的Apple Music应用程序中相同的动态状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为新 Apple Music应用中的 statusBar 动态着色?

Is it possible to have dynamically coloring statusBar which is in the new Apple Music app ?

编辑:

iOS 8.4中新的Apple Music应用具有此功能。

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.

编辑2:

Apple文档似乎现在不允许我们使用( iOS 8.4 )。将来可能会在 iOS 9 中提供。

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.

编辑3:
似乎尚未在 iOS 9 中提供。

推荐答案

99.99%的人确信这无法使用公共API轻松完成,因为我尝试了自己的几乎所有东西(我个人也不认为这是状态栏的一种神奇方法,但是相反,他们的应用程序是能够检索状态栏视图,然后对其应用蒙版)。

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).

我确信您可以做自己的StatusBar,并且有 MTStatusBarOverlay 库,很不幸,它很旧,因此我无法真正确定它是否有效,但似乎仍有人在使用它。

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:


  • 获取前20个像素的屏幕截图(状态栏)

  • 从该屏幕截图中,删除所有内容不是黑色(您可以对其进行改进,以便它搜索黑色边缘,这样可以保留绿色电池和透明性),这将使您的覆盖蒙版以及伪造的状态栏

  • 使用以下状态覆盖状态栏:背景视图掩盖了实际状态栏,以及您刚创建的Alpha图像

  • 对该图像应用蒙版,所有被蒙版的颜色都会变为白色阴影

  • 根据用户滚动条更改遮罩的高度

  • Take screenshot of top 20 pixels (status bar)
  • From that screenshot, remove everything that is not black (you can improve it so it searches for black edges, this way you can preserve green battery and transparency) This will make your overlay mask and also fake status bar
  • Overlay statusbar with : background view masking actual status bar, and the alpha-image you just created
  • Apply mask to that image, everything that is masked will change color to shades of white
  • Change height of the mask depending on user scroll

现在您应该能够正确滚动了d正确更改颜色。剩下的唯一问题是状态栏还没有激活,但是真的吗?滚动出来后,立即删除叠加层,使其刷新。滚动到最顶部时,您将执行相同的操作,但是在这种情况下,您将状态栏的颜色更改为白色(无动画),因此适合您的状态。

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.

希望它会有所帮助!

这篇关于与新的Apple Music应用程序中相同的动态状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆