GodAnimation
为您的视图和单元格提供简单动画
目录
安装
GodAnimation可通过CocoaPods获取。要安装它,只需将其添加到您的Podfile中的以下行
pod 'GodAnimation'
用法
首先,在您的swift文件中导入GodAnimation。
import "GodAnimation"
视图动画
展示示例代码
GodAnimation.animateView(type: .fromLeft, animatedView: view, vc: self) { }
参数 | 描述 |
---|---|
类型 | 动画类型 |
animatedView | 要动画化的视图 |
vc | 包含动画视图的ViewController |
动画类型
- fromLeft
- fromRight
- 从顶部
- 从底部
- 弹出进入
- 弹出退出
- 抖动
- 按钮点击
动画名称 | 示例 | 动画名称 | 示例 |
---|---|---|---|
fromLeft | 从顶部 | ||
fromRight | 从底部 | ||
弹出进入 | 弹出退出 | ||
抖动 | 按钮点击 |
单元格动画
展示示例代码
GodAnimation.cellAnimation(type: .cardDrop, cell: cell, indexPath: IndexPath) { }
参数 | 描述 |
---|---|
类型 | 动画类型 |
单元格 | 待动画单元格 |
索引路径 | 单元格索引路径 |
实际使用示例
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if !shownIndexes.contains(indexPath) {
shownIndexes.append(indexPath)
GodAnimation.cellAnimation(type: .zoom, cell: cell, indexPath: indexPath) { print("Animation done.") }
}
}
动画类型
- 透明度
- 波浪
- 从左到右
- 从上到下
- 弹跳
- 从右到左
- 旋转
- 线性
- 缩放
- 卡片下落
- 从右侧拖动
动画名称 | 示例 | 动画名称 | 示例 |
---|---|---|---|
透明度 | 波浪 | ||
从左到右 | 从上到下 | ||
弹跳 | 从右到左 | ||
旋转 | 线性 | ||
缩放 | 卡片下落 | ||
从右侧拖动 |