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

时间:2016-09-03 14:35:27

标签: ios objective-c 3dtouch

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

Contacts 3D Touch

2 个答案:

答案 0 :(得分:0)

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

要整合Peek and Pop,您可以按照此tutplus教程进行操作。

https://code.tutsplus.com/tutorials/ios-9-an-introduction-to-3d-touch--cms-25115

希望,这有帮助

答案 1 :(得分:-1)

您可以尝试我自己的库ActionsList,其外观和感觉与Apple的快速操作菜单相同。

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

首先,您应该创建列表。

如果您想要UIButtonUIBarButtonItem UITabBarItem的{​​{1}}来呈现它,可以使用内置方法创建列表:

// 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

ActionsListExample app