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>
相关推荐
Jouzzy3 小时前
【iOS安全】Dopamine越狱 iPhone X iOS 16.6 (20G75) | 解决Jailbreak failed with error
安全·ios·iphone
瓜子三百克3 小时前
采用sherpa-onnx 实现 ios语音唤起的调研
macos·ios·cocoa
左钦杨4 小时前
IOS CSS3 right transformX 动画卡顿 回弹
前端·ios·css3
努力成为包租婆6 小时前
SDK does not contain ‘libarclite‘ at the path
ios
安和昂1 天前
【iOS】Tagged Pointer
macos·ios·cocoa
I烟雨云渊T1 天前
iOS 阅后即焚功能的实现
macos·ios·cocoa
struggle20251 天前
适用于 iOS 的 开源Ultralytics YOLO:应用程序和 Swift 软件包,用于在您自己的 iOS 应用程序中运行 YOLO
yolo·ios·开源·app·swift
Unlimitedz1 天前
iOS视频编码详细步骤(视频编码器,基于 VideoToolbox,支持硬件编码 H264/H265)
ios·音视频
安和昂2 天前
【iOS】SDWebImage源码学习
学习·ios
ii_best2 天前
按键精灵ios脚本新增元素功能助力辅助工具开发(三)
ios