AASnackbar
描述
AASnackbar 在屏幕底部显示关于特定事件的短动画消息,并持续指定时长。
预览演示
安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖项管理器。要使用 CocoaPods 安装 AASnackbar
-
请确保已安装 CocoaPods。安装指南。
-
更新 Podfile 以包括以下内容:
use_frameworks!
pod 'AASnackbar'
- 运行
pod install
。
- 在您的代码中按以下方式导入 AASnackbar:
import AASnackbar
如何使用 AASnackbar
var snackBar : AASnackbar!
2) 从 AASnackbar 创建对象 3.1) 无操作
// send the current view frame and set the text with duration, and animation type fade or translation.
snackBar = AASnackbar(addedToView: self.view, title: "No internet connection", duration: 3.0,animationType:.fade)
snackBar.setTextColor(UIColor.white)
snackBar.show()
3.2) 带操作
// send the current view frame and set the text with duration, by setting button title makes button visible
snackBar = AASnackbar(addedToView: self.view, title: "No Internet connection",buttonTitle: "OK", duration: 3.0,animationType: .translation)
snackBar.setButtonTextColor(UIColor(red: 76/255, green: 175/255, blue: 80/255, alpha: 1.0))
snackBar.addButtonAction(#selector(ViewController.showAlert(_:)), view: self)
snackBar.show()
3.3) 快捷显示
AASnackbar(addedToView: self.view, title: "No Internet connection",buttonTitle: "OK", duration: 3.0,animationType: .translation).show()
4) 隐藏 AASnackbar(可选)
// By default snackbar has duration to show and hide itself,this can be used to force hiding snackbar while its currently showing. so if you are showing the snackbar with fade then use fade to hide and same for translation.
snackBar.hideWithFade(1.0, delay: 0.0)
snackBar.hideWithTranslation(1.0, delay: 0.0)
自定义
以下是可以从基本视图控制器自定义的所有 AASnackbar 属性。
backgroundColor = UIColor
setTextColor(UIColor)
setButtonTextColor(UIColor)
addButtonAction(selector, view: UIViewController)
hideWithFade(duration: NSTimeInterval, delay: NSTimeInterval)
hideWithTranslation(duration: NSTimeInterval, delay: NSTimeInterval)
barHeight = 60
需求
- Swift 5.0+
- IOS 9.0+
许可证
MIT许可(MIT)
版权所有 © AaoIi 2015
在此,任何人免费获得本软件及其相关文档副本(以下简称“软件”),对本软件进行不受限制的交易,包括但不限于以下权利:使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本;允许获得软件副本的个人进行上述操作,但应遵守以下条件:
上述版权声明和本许可声明应包含在软件的任何副本或主要部分中。
本软件按“原样”提供,不提供任何形式(明示或暗示)的保证,包括但不限于适销性、适用于特定目的和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论责任成立的法律根据是合同、侵权还是其他方式,无论索赔、损害或其他责任是由软件、使用或其他方式不可分割的。