CFNotify 1.0.3

CFNotify 1.0.3

hallelujahbaby 维护。



CFNotify 1.0.3

  • 作者:
  • Johnny

CFNotify

Travis branch GitHub issues Swift GitHub forks GitHub stars GitHub license Carthage compatible CocoaPods

CFNotify 使用 Swift 编写,使用 UIKit Dynamics 作为动画器。它可以使任何 `UIView` 对象变得 可拖动可抛掷。此库主要用于 应用内通知警报。让我们以更互动和有趣的方式通知并提醒您的用户!

Demo1 Demo2 Demo3

特性

  • 与任何 UIView 对象一起工作!
  • 使用 UIKit Dynamics。轻量级和流畅!
  • 高度可定制
  • 包含 三个 即用型视图:CyberViewClassicViewToastView
  • 简单实现

要求

  • Swift 4.0+
  • Xcode 9
  • iOS 9.0+

变更日志

请阅读 CHANGELOG.md

安装

  • Carthage (推荐)

    将以下行添加到 Cartfile

    #CFNotify
    github "hallelujahbaby/CFNotify"

    运行 carthage update 并将 CFNotify.frameworkCFResources.bundle 添加到您的项目中

  • Cocoapods

    将以下行添加到 Podfile

    pod "CFNotify"

入门

在源代码中有一个 示例项目。建议您先查看并熟悉这个框架。

基础

这是具有所有 默认 设置的基本功能,设计您自己的 UIView 或使用 CFNotifyView 来创建一个。

CFNotify.present(view: UIView)

如果您需要更多的 自定义 设置,创建您自己的 Config 并使用以下功能。

CFNotify.present(config: Config, view: UIView)

如果您想要 自定义tap 操作,请使用以下功能。(如果您使用 tapHandler,则会覆盖默认的点击以隐藏操作)

CFNotify.present(config: Config, view: UIView, tapHandler: (()->Void)?)

CFNotify 将所有要显示的视图放入队列(先进先出)。您可以使用以下函数编程方式隐藏视图。

CFNotify.hide() // hide the current view

CFNotify.hideAll() // hide all the views in queue (Clear the queue)

CFNotifyView

您可以使用CFNotifyView类快速简单地创建一个警报视图。

CFNotifyView目前包括 3视图CyberClassicToast

每种风格都有 4主题信息成功失败警告

每个主题都有 2样式浅色深色

  • 网络风

    CyberView
    let cyberView = CFNotifyView.cyberWith(title: "Title",
                                            body: "Body",
                                           theme: .Info(.Light))
    
    //More customizations
    let customCyberView = CFNotifyView.cyberWith(titleFont: UIFont,
                                                titleColor: UIColor,
                                                  bodyFont: UIFont,
                                                 bodyColor: UIColor,
                                           backgroundColor: UIColor,
                                                 blurStyle: UIBlurEffectStyle)
  • 经典式

    ClassicView
    let classicView = CFNotifyView.classicWith(title: "Title",
                                                body: "Body",
                                               theme: .Success(.Light))
    
    //More customizations
    let customClassicView = CFNotifyView.classicWith(titleFont: UIFont,
                                                    titleColor: UIColor,
                                                      bodyFont: UIFont,
                                                     bodyColor: UIColor,
                                               backgroundColor: UIColor)
  • 吐司

    ToastView
    let toastView = CFNotifyView.toastWith(text: "Text",
                                          theme: .Fail(.Dark))
    
    //More customizations
    let customToastView = CFNotifyView.toastWith(text: String,
                                             textFont: UIFont,
                                            textColor: UIColor,
                                      backgroundColor: UIColor)                                    

配置

您可以使用Config类来配置CFNotify。该类包含许多属性,以下三个是最常见的:

  • initPosition:视图出生的位置
  • appearPosition:视图显示的位置
  • hideTime:视图将在hideTime后自动隐藏(默认为3秒)

示例

var classicViewConfig = CFNotify.Config()
classicViewConfig.initPosition = .top(.random) //the view is born at the top randomly out of the boundary of screen
classicViewConfig.appearPosition = .top //the view will appear at the top of screen
classicViewConfig.hideTime = .never //the view will never automatically hide

委托

CFNotify 为一些常见事件提供了 委托 方法。您需要遵守 CFNotifyDelegate

func cfNotifyDidAppear() {}

func cfNotifyStartDragging(atPoint: CGPoint) {}

func cfNotifyIsDragging(atPoint: CGPoint) {}

func cfNotifyEndDragging(atPoint: CGPoint) {}

func cfNotifyDidDisappear() {}

func cfNotifyIsTapped() {}

待办事项列表

  • 添加 SPM 支持
  • 改进示例应用
  • 添加带按钮的提醒视图
  • 完整文档

错误和问题

如果您发现任何错误或遇到任何与此框架相关的问题,请随意在 问题页面 中打开新的问题。

贡献

欢迎您为此项目做出贡献,请随意 提交拉取请求

许可证

CFNotify 采用 MIT 许可证 发布。详细信息请见 LICENSE