效果图
3DTouch.gif代码块
info.plist中添加,最多四个选项,及时添加超过四个也只会显示四个
<key>UIApplicationShortcutItems</key>
<array>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeShare</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Share</string>
<key>UIApplicationShortcutItemType</key>
<string>Share</string>
</dict>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeShare</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Share0</string>
<key>UIApplicationShortcutItemType</key>
<string>Share0</string>
</dict>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeShare</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Share1</string>
<key>UIApplicationShortcutItemType</key>
<string>Share1</string>
</dict>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeShare</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Share2</string>
<key>UIApplicationShortcutItemType</key>
<string>Share2</string>
</dict>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeShare</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Share3</string>
<key>UIApplicationShortcutItemType</key>
<string>Share3</string>
</dict>
</array>
3DTouch回调方法
//<UIApplicationShortcutItem: 0x6040004779c0; type: Share1, title: Share1>
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
}
网友评论