SSLocalNotification 0.1.2

SSLocalNotification 0.1.2

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released最后发布2017年6月
SwiftSwift 版本3.0
SPM支持 SPM

Nicholas Bellucci 维护。



SSLocalNotification

SSLocalNotification 是一个轻量且易于使用的本地通知警报。

亮点

  • [x] 可以根据需要自定义图片、标题和消息
  • [x] 可以设置允许展开的通知。
  • [x] 在展开通知时可以添加操作。
  • [x] 可以设置通知在屏幕上的时间。
  • [x] 支持自定义触摸或关闭时的函数。

未来计划

  • [x] 为通知添加暗黑模式。
  • [x] 允许通知中不包含图片。
  • [x] 使用文本框的快速响应通知。

要求

  • ARC
  • iOS8

安装

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 文件。