测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
Released最后发布 | 2017年6月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Nicholas Bellucci 维护。
SSLocalNotification 是一个轻量且易于使用的本地通知警报。
SSLocalNotification 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "SSLocalNotification"
以下是您可以使用 SSLocalNotification
的示例。
导入 SSLocalNotification
import SSLocalNotification
为了创建一个基本的通知,您需要这些
let notification = SSLocalNotificationController(title: "SSLocalNotification", message: "This is a test notification!", preferredStyle: .light)
notification.image = UIImage()
notification.setTitleFont(fontName: "Avenir-Medium", color: .black)
notification.setMessageFont(fontName: "Avenir-Book", color: .black)
notification.presentLocalNotification()
从那里,您可以添加操作,如下所示
notification.addAction(action: SSLocalNotificationAction(title: "Button 1", fontName: "Avenir-Book", tint: .blue, handler: {
print("Custom Action")
}))
notification.addAction(action: SSLocalNotificationAction(title: "Button 2", fontName: "Avenir-Book", tint: .blue, handler: {
print("Custom Action")
}))
SSLocalNotification 还有一些可自定义的属性(很快还将增加更多)
// Make the notification expandable
notification.expandable = true
// Change how long the notification is presented
notification.dismissDelay = 4.0
// Add action when user taps the notification
notification.didTapLocalNotification = tapFunction()
// Add action when user dismisses the notification
notification.didTapLocalNotification = dismissFunction()
Nicholas Bellucci,[email protected]
SSLocalNotification 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。