【问题标题】:Change iOS 10 notification image thumbnail size更改 iOS 10 通知图像缩略图大小
【发布时间】:2016-12-22 05:30:10
【问题描述】:

我是 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

有可能吗?

【问题讨论】:

  • 你发现了吗?
  • 我也遇到了这个问题。图标很小,尽管源 png 文件足够大

标签: swift notifications ios10


【解决方案1】:

不,这不可能,iOS 确定最大尺寸。

【讨论】:

    【解决方案2】:

    在 iOS 10 中,您可以使用UserNotificationsUI 框架将通知正文替换为具有更大UIImageView 缩略图的通知正文。 详情请见Customizing the Appearance of Notifications

    【讨论】:

      猜你喜欢
      • 2019-02-09
      • 2014-09-17
      • 1970-01-01
      • 2018-06-18
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      • 1970-01-01
      • 2012-01-27
      相关资源
      最近更新 更多