iOS应用程序内的3D Touch Quick Actions

问题描述 投票:2回答:2

我正在开发支持3D Touch的移动应用程序。我想为应用内的一些控件实现一个Quick Action菜单,比如Contacts app。我附上截图以便更好地理解。

Contacts 3D Touch

ios objective-c 3dtouch
2个回答
0
投票

要在应用内添加这些快速操作,您可以在应用中实现Peek and Pop功能。

要集成qazxsw opi,您可以按照此tutsplus教程进行操作。

Peek and Pop

希望能帮助到你


-1
投票

您可以尝试我自己的库https://code.tutsplus.com/tutorials/ios-9-an-introduction-to-3d-touch--cms-25115,其外观和感觉与Apple的Quick Actions菜单相同。

它还没有3D Touch支持,但它可以帮助您呈现与提供者屏幕截图相同的操作列表。

首先你应该创建列表。

如果你想从ActionsListUIButtonUIBarButtonItem展示它,有内置的方法来创建列表:

UITabBarItem

否则你应该使用// element is UIButton, UIBarButtonItem or UITabBarItem let list = element.createActionsList() 结构:

ActionsListModel

然后向列表添加操作

let list = ActionsListModel(senderView: viewThatInitiatedListPresenting,
                            sourceView: viewToPresentListFrom,
                            delegate: listDelegate)

之后,您可以列出清单

list.add(action: ActionsListDefaultButtonModel(localizedTitle: "Create Alarm", 
                 image: UIImage(named: "Alarm clock"),
                 action: { action in
                     // You can use action's list property to control it

                     // - To dismiss
                     action.list?.dismiss()

                     // - To update action appearance
                     action.appearance.//anything
                     // Do not forget to reload actions to apply changes
                     action.list?.reloadActions()
          }))

list.present() // Save list or it will be deallocated and not reachable outside of the scope it was created in self.list = list

© www.soinside.com 2019 - 2024. All rights reserved.