微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

swift – 更改iOS 10通知图像缩略图大小

我是 XcodeSwift的新手.我想发送带有显示图像的本地通知.我使用UNNotificationAttachment附加以下代码中的图像:

let content = UNMutableNotificationContent()
content.title = "Testing"
content.body = "Testing rich notification"   
let attachement = try! UNNotificationAttachment(identifier: "image",url: Bundle.main.url(forResource: "myImg",withExtension: "png")!,options: nil)
content.attachments = [attachement]    
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 10,repeats: false)
let request = UNNotificationRequest(identifier: "TenSecond",content: content,trigger: trigger) // Schedule the notification.            
let center = UNUserNotificationCenter.current()
center.add(request) { (error : Error?) in
    if error != nil {}
}

我可以在通知横幅的右侧看到一个缩略图,但它太小了.我想增加缩略图的大小,以便通知如下所示:

Notification With larger thumbnail

可能吗?

解决方法

使用iOS 10,您可以使用UserNotificationsUI框架将通知主体替换为具有较大UIImageView的缩略图.
有关详情,请参见 Customizing the Appearance of Notifications.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐