NotifiOS 0.1.0

NotifiOS 0.1.0

测试已测试
语言语言 SwiftSwift
许可协议 MIT
发布最新版本2016年5月
SPM支持 SPM

Ardalan Samimi 维护。



NotifiOS 0.1.0

  • 作者
  • Ardalan Samimi

NotifiOS

概述

使用 NotifiOS 创建用户通知,这是一个很小且易用的 Swift 库(继承自 UIView)。

要求

  • iOS 8

用法

建议您使用便利初始化器 init(withMaxDimensions:) 创建 NotifiOS,在此初始化器中输入视图的最大尺寸,因为它将根据内容自动调整大小。最大尺寸属性将确保它不会超过某个尺寸。

let view = NotifiOS(withMaxDimensions: CGSize(width: 250, height: 250))

NotifiOS 主要由两个子视图组成:一个文本标签和一个图像视图。要设置视图的图像,请使用 setImage(_:withSize:) 方法,其中 withSize 应提供图像的首选尺寸。请使用 setTitle(_) 方法设置标题。

let image = UIImage(named: "SomeImage")
view.setImage(image, withSize: CGSize(width: 65, height: 70))
view.setTitle("Some Title!")

NotifiOS 还提供了一个活动指示器。注意:活动状态下的旋转条将隐藏图像。

view.loadActivityIndicator()
view.setTitle("Loading...")
view.delayFadeOut = 0 // To make sure the view will not go away
view.removeOnTouch = false

// Change the image after the loading is done:
let image = UIImage(named: "SomeImage")
view.setImage(image, withSize: CGSize(width: 65, height: 70))
view.setTitle("Did Load!")
view.beginFadeOut()

除非另外配置,否则 NotifiOS 在视图设置为子视图后 1 秒开始淡入(有关配置,请参见下面)。

someSuperView.addSubview(view)

配置

自定义 NotifiOS 体验。

view.fadeDuration = 5 // The duration of the fade.
view.delayFadeOut = 5 // The number of seconds the view should be displayed. If set to 0, the view will stay until the beginFadeout() method is called.
view.removeOnTouch = true // If true, the view will start the fadeout process when the user taps it.
view.afterTouch = {
  // The callback that will be fired after the fadeout has finished.
}

您还可以自定义标题、图像视图和活动指示器元素。

示例

这个仓库包含一个示例项目。要运行示例项目,请先从该仓库克隆,然后在 Example 目录中首先运行 pod install。

作者

Ardalan Samimi,[email protected]

许可协议

NotifiOS 基于 MIT 许可协议提供。有关更多信息,请参阅 LICENSE 文件。