Last active
January 5, 2020 14:11
-
-
Save ycui1/f3fc47059582bc2395bd69c752360f7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func sceneWillResignActive(_ scene: UIScene) { | |
var shortcutItems = UIApplication.shared.shortcutItems ?? [] | |
if shortcutItems.isEmpty { | |
shortcutItems += [ | |
UIApplicationShortcutItem(type: "Test Type 0", localizedTitle: "Test Title 0"), | |
UIApplicationShortcutItem(type: "Test Type 1", localizedTitle: "Test Title 1") | |
] | |
} else { | |
if let mutableShortcutItem = shortcutItems.first?.mutableCopy() as? UIMutableApplicationShortcutItem { | |
mutableShortcutItem.type = "Updated Type 0" | |
mutableShortcutItem.localizedTitle = "Updated Title 0" | |
mutableShortcutItem.icon = UIApplicationShortcutIcon(type: UIApplicationShortcutIcon.IconType.love) | |
shortcutItems[0] = mutableShortcutItem | |
} | |
} | |
UIApplication.shared.shortcutItems = shortcutItems | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment