问题描述
iOS 10有一个我想要复制的功能。当您在Apple Music应用程序中3D触摸相册时,它会打开下面显示的菜单。然而,与普通的偷窥和流行音乐不同,当你举起手指时,它不会消失。我该如何复制?
iOS 10 has a feature I would like to replicate. When you 3D touch an album in the Apple Music app it opens the menu shown below. However unlike a normal peek and pop, it does not go away when you raise you finger. How do I replicate this?
推荐答案
实际上可以使用 UIPreviewInteraction API 来完成。
This actually might be done using UIPreviewInteraction API.
它几乎类似于 Peek和Pop API 。
这里有两个阶段:预览和提交,分别对应Peek和Pop在后来的API中。我们有,它让我们可以访问这些阶段的过渡。
Here we have 2 phases: Preview and Commit which are corresponding to the Peek and Pop in the later API. we have UIPreviewInteractionDelegate which gives us the access to the transition through these phases.
那么应该做的是复制上面的Apple Music Popup,
So what one should do is, to replicate the above Apple Music Popup,
-
在
构建上述菜单的xib并在期间显示它/ p>
Build an xib of the above menu and show it during didUpdateCommitTransition
实际上,apple已经以聊天应用程序的形式构建了一个这样的演示。
Actually, apple has built a demo of this in the form of a Chat App.
从并测试它。
这篇关于如何复制iOS 10的Apple Music“Peek and pop action menu”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!