目录
#AANotifier
##描述
AANotifier 允许您创建基于 UIView 的片段,以便在运行时显示在屏幕上。它旨在使自定义元素在 UIView 中动画化,甚至从基于 xib 的视图开始。
##演示
AANotifier 可以是自定义弹出视图、操作栏、消息显示横幅等。
要运行示例项目,先克隆仓库,然后从 Example 目录运行 pod install
命令。
##要求
- iOS 8.0+
- Xcode 8.0+
- Swift 3+
安装
AANotifier
可以通过 CocoaPods、Carthage 或手动安装。
##CocoaPods
AANotifier
在 CocoaPods 中可用。要安装 CocoaPods,运行
gem install cocoapods
然后创建一个包含以下内容的 Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AANotifier' , '1.2'
end
最后,运行以下命令来安装它
$ pod install
##Carthage
要安装 Carthage,运行(使用 Homebrew)
$ brew update
$ brew install carthage
然后添加以下行到您的 Cartfile
github "EngrAhsanAli/AANotifier" "master"
然后将其导入到您使用它的所有文件中
import AANotifier
##手动安装
如果您不希望使用上述的任何依赖管理器,您可以通过将 Classes 文件夹中包含的文件添加到项目中手动将 AANotifier
集成到您的项目中。
入门
## 定义您的通知器!
您可以在视图控制器中通过懒初始化选项简单地定义您的通知器。
用法
lazy var myNotifier: AANotifier = {
let notifierView = UIView.fromNib(nibName: "MyNotifier")!
let options: [AANotifierOptions] = [
.transitionA(.fromBottom, 0.9), // Show notifier animation
.transitionB(.toBottom, 0.9), // Hide notifier animation
.position(.bottom), // notifier position
.preferedHeight(50), // notifier height
.margins(H: 60, V: 40), // notifier margins
.hideOnTap, // Hides on tap
.deadline(2.0) // Deadline of notifier for dismissal
]
let notifier = AANotifier(notifierView, withOptions: options)
return notifier
}()
## 显示您的通知器!您可以通过 show
方法或 animateNotifer
方法来简单地显示通知器,添加动画选项。
用法
// Show simply!
myNotifier.show()
// Tap listner
notifier.didTapped = {
notifier.hide()
}
## 隐藏您的通知器!
您可以通过 hide
方法简单地隐藏通知器。
用法
// Show hide!
myNotifier.hide()
## AANotifier 选项
您可以为您的通知器使用以下通知器选项
选项 | 类型 | 描述 |
---|---|---|
preferredHeight |
CGFloat |
AANotifier 的高度 |
transitionA |
AAViewAnimators, TimeInterval |
显示通知器的动画器 |
transitionB |
AAViewAnimators, TimeInterval |
隐藏通知器的动画器 |
position |
AANotifierPosition |
AANotifier 的位置 |
hideOnTap |
--- |
如果添加了则点击隐藏 |
margins |
(CGFloat?, CGFloat?) |
水平方向和垂直方向的边距 |
## 贡献与许可
AANotifier
可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。
欢迎 pull requests!最佳贡献将包括替换或配置已知在典型应用程序生命周期中阻止主线程的类/方法。
如果您正在应用中使用 AANotifier
,请发送电子邮件给 Engr. Ahsan Ali