加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 04:27:49 所属栏目:百科 来源:网络整理
导读:我是 Xcode和 Swift的新手.我想发送带有显示图像的本地通知.我使用UNNotificationAttachment附加以下代码中的图像: let content = UNMutableNotificationContent()content.title = "Testing"content.body = "Testing rich notification" let attachement =
我是 Xcode和 Swift的新手.我想发送带有显示图像的本地通知.我使用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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读