如何在 iOS 中的应用程序意图的快捷方式应用程序中拥有类似小部件的条目?

问题描述 投票:0回答:1

我指的是让应用程序意图看起来像快捷方式应用程序中的这些小部件。这是可能的还是只为苹果应用程序保留?

我认为为 AppShortcutsProvider 中返回的 AppShortcuts 添加一个 ShortTitle 和 systemImageName 就足够了,但我得到的只是每个条目的单独卡片,而不是类似小部件的部分。

ios swift shortcut sirishortcuts appintents
1个回答
0
投票

您需要根据您的意图创建一个

AppShortcutProvider
。提供一个简短的标题和 systemImage 将提供图像

例如

struct TaskAppShortcutProvider: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] = [
    AppShortcut(intent: MarkTaskCompleteIntent(),
                phrases: ["Complete Tasks in \(.applicationName)"],
                shortTitle: "Complete Task",
                systemImageName: "checkmark"),
    AppShortcut(intent: AddTaskIntent(), phrases: ["Add task to \(.applicationName)"], shortTitle: "Add Task", systemImageName: "plus")
    
    ]
}

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