CRNotifications
CRNotifications是自定义的、包含3种布局的内置通知。当它们被点击或自动消失时,通知将会有进出国画的动画效果。
屏幕截图
通知类型
成功 | 错误 | 信息 |
---|---|---|
如何使用
调用CRNotifications.showNotification
方法,传入标题、消息、通知类型和通知显示时长。如果通知不需要自动消失,请使用时长为0
。您还可以传递一个完成块,一旦通知消失就会执行该块。
内置通知类型有:.success
、.error
、.info
。
示例
CRNotifications.showNotification(type: CRNotifications.success, title: "Success!", message: "You successfully showed this notification.", dismissDelay: 3)
您也可以通过以下方法之一来自定义通知并提供自己的自定义样式:
showNotification(textColor:, backgroundColor: UIColor, image: UIImage?, title: String, message: String, dismissDelay: TimeInterval)
或者通过遵循CRNotificationType
协议来定制。
protocol CRNotificationType {
var textColor: UIColor { get }
var backgroundColor: UIColor { get }
var image: UIImage? { get }
}
安装
Cocoapods安装
Swift 5
pod 'CRNotifications'
Swift 4.2
pod 'CRNotifications', :git => 'https://github.com/dkcas11/CRNotifications.git', :branch => 'swift4-2'
Swift 3
pod 'CRNotifications', :git => 'https://github.com/dkcas11/CRNotifications.git', :branch => 'swift3'
手动安装
将CRNotifications文件夹拖入您的项目中即可。
作者 & 贡献者
Casper Riboe(作者)
Facebook: Casper Riboe
Twitter: dkcas11
邮箱: [email protected]
Herrick Wolber(贡献)
Twitter: estar2005
Github: Rico237
邮箱: [email protected]