Watchos中的本地通知窗帘颜色
我正在尝试更改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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论