用于自定义通知的UIUserNotification

时间:2016-08-10 06:32:19

标签: ios swift

我想用像Viber通知这样的图像来自定义我的iOS应用通知吗? UIUserNotification会允许这个吗?怎么做?

enter image description here

任何人都可以提供帮助吗?

1 个答案:

答案 0 :(得分:0)

在这里,您是一个可以在应用程序通知中自定义的库:

enter image description here

https://github.com/hyperoslo/Whisper

安装

Whisper可以通过CocoaPods获得。要安装它,只需将以下行添加到Podfile:

pod 'Whisper'

用法

组件的使用非常简单,你只需要在Whisper的情况下创建一条消息,在Shout的情况下发布消息,或者在Whistle的情况下创建一个Murmur,它是这样完成的:

对于一个耳语:

let message = Message(title: "Enter your message here.", backgroundColor: UIColor.redColor())
// Show and hide a message after delay
show(whisper: message, to: navigationController, action: .Show)
// Present a permanent message
show(whisper: message, to: navigationController, action: .Present)
// Hide a message
hide(whisperFrom: navigationController)

对于喊叫:

let announcement = Announcement(title: "Your title", subtitle: "Your subtitle", image: UIImage(named: "avatar"))
show(shout: announcement, to: navigationController, completion: {
  print("The shout was silent.")
})