通知气泡 0.1.1

通知气泡 0.1.1

Pacu Gindre 维护。



  • 作者:
  • Francisco Gindre

NotificationBubbles

示例

要运行示例项目,克隆仓库,然后首先从 Example 目录运行 pod install

NotificationBubble 是一个类,它基于定义其样式的 Options 在 UIView 中显示通知。

示例:使用可以处理触摸事件的气泡从文本框显示文本输入。

  NotificationBubble.display(in: self.view, options: options, attributedText: NSAttributedString(string: self.textField.text ?? ""), handleTap: {
        self.present(UIAlertController.init(title: "", message: "bubble tapped", preferredStyle: UIAlertController.Style.alert), animated: true, completion: nil)
    
        })

一个带有 20p 边距的绿色气泡

public extension NotificationBubble {
    public static func sucessOptions(animation: NotificationBubble.Animation) -> [NotificationBubble.Style] {
        return [ NotificationBubble.Style.animation(animation),
                 NotificationBubble.Style.margins(UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0)),
                 NotificationBubble.Style.cornerRadius(8),
                 NotificationBubble.Style.duration(timeInterval: 5),
                 NotificationBubble.Style.backgroundColor(UIColor.green)]
    }

一个红色气泡

    public static func errorOptions(animation: NotificationBubble.Animation) -> [NotificationBubble.Style] {
        return [ NotificationBubble.Style.animation(animation),
                 NotificationBubble.Style.margins(UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0)),
                 NotificationBubble.Style.cornerRadius(8),
                 NotificationBubble.Style.duration(timeInterval: 5),
                 NotificationBubble.Style.backgroundColor(UIColor.red)]
    }

一个灰色气泡

    public static func neutralOptions(animation: NotificationBubble.Animation) -> [NotificationBubble.Style] {
        return [ NotificationBubble.Style.animation(animation),
                 NotificationBubble.Style.margins(UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0)),
                 NotificationBubble.Style.cornerRadius(8),
                 NotificationBubble.Style.duration(timeInterval: 5),
                 NotificationBubble.Style.backgroundColor(UIColor.lightGray)]
    }
}

安装

通知气泡可通过 CocoaPods 获取。要安装它,只需将以下行添加到 Podfile 中即可

pod 'NotificationBubbles'

用法

请参阅示例项目

作者

Francisco Gindre,[email protected]

许可证

NotificationBubbles 依据 MIT 许可证提供。有关更多信息,请参阅 LICENSE 文件。