ios 配置快捷指令

js 复制代码
struct OpenIntent: AppIntent {
    @available(iOS 16, *)
    static var title = LocalizedStringResource("这里填写标题")
    @available(iOS 16.0, *)
    static var description = IntentDescription("这里填写描述")
    
    // 意图执行时,是否自动将应用拉起到前台
    static var openAppWhenRun: Bool = true
    
    @available(iOS 16.0, *)
    func perform() async throws -> some IntentResult {
        //这样写会有一个dialog提示
//        return .result(dialog: "play")
  //这样写没有弹窗
        return .result()
    }
}

struct MeditationShortcuts: AppShortcutsProvider {
  
    @available(iOS 16.0, *)
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: OpenIntent(),
            phrases: [
                "\(.applicationName) aaa",//这里必须有\(.applicationName) 否则在快捷指令里面搜索不到
            ],
            //shortTitle 跟 systemImageName 最好一起写
            shortTitle: "charge",
            systemImageName: "battery.100percent.bolt" 
        );
        
    }
}

设置systemImageName 的颜色以及在快捷指令中显示的背景色

info.plist 中添加

CustomTintColor BackgroundGradientColor1 BackgroundGradientColor2 都是设置的颜色资源的名字

xml 复制代码
<dict>
     <key>CFBundlePrimaryIcon</key>
     <dict>
         <key>NSAppIconActionTintColorName</key>
         <string>CustomTintColor</string>
         <key>NSAppIconComplementingColorNames</key>
         <array>
             <string>BackgroundGradientColor1</string>
             <string>BackgroundGradientColor2</string>
         </array>
    </dict>
</dict>
相关推荐
mascon9 分钟前
U3D打包IOS的自我总结
ios
名字不要太长 像我这样就好15 分钟前
【iOS】继承链
macos·ios·cocoa
karshey1 小时前
【IOS webview】IOS13不支持svelte 样式嵌套
ios
潜龙95271 小时前
第4.3节 iOS App生成追溯关系
macos·ios·cocoa
游戏开发爱好者810 小时前
iOS App 电池消耗管理与优化 提升用户体验的完整指南
android·ios·小程序·https·uni-app·iphone·webview
神策技术社区17 小时前
iOS 全埋点点击事件采集白皮书
大数据·ios·app
wuyoula18 小时前
iOS V2签名网站系统源码/IPA在线签名/全开源版本/亲测
ios
2501_9159184118 小时前
iOS 性能监控工具全解析 选择合适的调试方案提升 App 性能
android·ios·小程序·https·uni-app·iphone·webview
fishycx18 小时前
iOS 构建配置与 AdHoc 打包说明
ios
90后的晨仔19 小时前
ios 集成阿里云的AI智能体报错CocoaPods could not find compatible versions for pod "AUIAICal
ios