Gallery Banner

Version Carthage Compatible License Platform Swift

github "impresyjna/ImpressiveNotifications"

pod 'ImpressiveNotifications', :git => 'https://github.com/impresyjna/ImpressiveNotifications', :branch => 'master'

INNotifications.show(type: .danger, data: INNotificationData(title: "Error", description: "Error notification"))

自定义样式

INNotificationStyle 是为了自定义通知外观而创建的结构。

public struct INNotificationStyle {
    let cornerRadius: CGFloat?
    let backgroundColor: UIColor?
    let titleColor: UIColor?
    let descriptionColor: UIColor?
    let imageSize: CGSize?
}

INNotifications.show(type: .danger, data: INNotificationData(title: "Error", description: "Error notification"), customStyle: INNotificationStyle(cornerRadius: 10.0, backgroundColor: .black, titleColor: .red, descriptionColor: .yellow, imageSize: CGSize(width: 100.0, height: 100.0)))

自定义数据、时间以及完成处理器

INNotificationData 是创建用于在通知中自定义数据、时间并在点击时添加完成处理器的结构。

public struct INNotificationData {
    let title: String
    let description: String?
    let image: UIImage?
    let delay: TimeInterval
    let completionHandler: (() -> Void)?
}

INNotifications.show(type: .danger, data: INNotificationData(title: "Danger", description: "Danger notification", image: UIImage(named: "danger"), delay: 20.0, completionHandler: {
            print("Hello")
    } 
))

自定义视图

还可以添加在Storyboard中创建的自定义视图。

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "CustomViewController")

INNotifications.show(type: .custom(vc.view))