How to show double height green statusbar (In-Call) in foreground app on device?

我怕爱的太早我们不能终老 提交于 2019-12-05 04:03:41

I have made an investigation of both apps (WhatsApp & Skype) and learned that they used their own UIView for achieving this functionality.

This is Skype:

This is WhatsApp (Reveal can't get real snapshot, but it transmits basic idea):

In both apps it is a UIView which starts on top of the screen and several methods for format output text / handle touch on it.

In iOS 10 Apple introduced CallKit.framework, but it seems that it has not that kind of functionality too, so the only way to do it - do it yourself.

Roman Ermolov's answer explained that some apps use their own UIView for this functionality, but does not explain how. The way I see it, you have a few options.

If you want to lay the view on top of (and covering) the current view controller, you could create a UIView with a UILabel or your own UIWindow and add that as a subview of your applications' keyWindow.

To have the view stick on top without covering the contents of the view controller, you could take the same approach as above and manually resize the application window or window's root view controller when you add the call bar subview. Alternatively, you could create a UIViewController base class which contains this call bar subview and an outlet for the view's height constraint. The default value of this constraint should be zero. Then, when a call is placed, change the height constraint to your desired call back height. This constraint approach might work on the application's UIWindow as well, but I'm not too familiar with using constraints on an application's window.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!