Watchos中的本地通知窗帘颜色

发布于 2025-02-07 22:48:15 字数 1061 浏览 0 评论 0原文

我正在尝试更改WatchKit应用程序中本地通知的窗扇颜色:

import SwiftUI
import UserNotifications

class myHostingController: WKUserNotificationHostingController<NotificationView> {
    let sashColor = sashColor
}

func addNotification() {
    let center = UNUserNotificationCenter.current()
    let sashColor = myHostingController.sashColor
    
    let addRequest = {
        let content = UNMutableNotificationContent()
        content.title = "Title content"
        content.sound = UNNotificationSound.default
        sashColor?.foregroundColor(.blue)
        
        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
        let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
        center.add(request)  
    }

我收到错误消息

呼叫“前景彩色”的结果未使用

我不知道如何调用sashcolor。任何见解都将不胜感激。

根据文档应该可以定制窗框颜色:

最终/developer.apple.com/design/human-interface-guidelines/components/system-experiences/notifications

I'm trying to change the sash color of a local notification in my WatchKit app:

import SwiftUI
import UserNotifications

class myHostingController: WKUserNotificationHostingController<NotificationView> {
    let sashColor = sashColor
}

func addNotification() {
    let center = UNUserNotificationCenter.current()
    let sashColor = myHostingController.sashColor
    
    let addRequest = {
        let content = UNMutableNotificationContent()
        content.title = "Title content"
        content.sound = UNNotificationSound.default
        sashColor?.foregroundColor(.blue)
        
        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
        let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
        center.add(request)  
    }

I get the error message

Result of call to 'foregroundColor' is unused

I can't figure out how to call sashColor. Any insights would be greatly appreciated.

Customizing the sash color should be possible according to the documentation:
https://developer.apple.com/documentation/swiftui/wkusernotificationhostingcontroller/sashcolor?changes=latest_beta

https://developer.apple.com/design/human-interface-guidelines/components/system-experiences/notifications

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文