Sample code on dynamic UIApplicationShortcutItems

前端 未结 4 908
眼角桃花
眼角桃花 2021-02-04 10:32

I\'m looking after some Obj-C sample code for a dynamic UIApplicationShortCutItem.

Basically, I have three static UIApplicationShortcutItems an

4条回答
  •  失恋的感觉
    2021-02-04 10:58

    For someone who is looking for a Swift4 version for @chengpei answer, it is here:

    let photoIcon = UIApplicationShortcutItem(type: "Selfie", localizedTitle:"Take selfie", localizedSubtitle: "Loc Subtitle", icon: nil, userInfo:nil)
    let videoIcon = UIApplicationShortcutItem(type: "Video", localizedTitle:"Take video", localizedSubtitle: "Loc Subtitle for Video", icon: UIApplicationShortcutIcon(type: .captureVideo), userInfo:nil)
    UIApplication.shared.shortcutItems = [photoIcon, videoIcon]
    

提交回复
热议问题