GodAnimation 0.0.5

GodAnimation 0.0.5

daoinek维护。



  • 作者:
  • Kostiantyn Bershov

GodAnimation

为您的视图和单元格提供简单动画

Generic badge made-with-swift GitHub license

目录

安装

GodAnimation可通过CocoaPods获取。要安装它,只需将其添加到您的Podfile中的以下行

pod 'GodAnimation'

用法

首先,在您的swift文件中导入GodAnimation。

import "GodAnimation"

视图动画

展示示例代码

GodAnimation.animateView(type: .fromLeft, animatedView: view, vc: self) { }
参数 描述
类型 动画类型
animatedView 要动画化的视图
vc 包含动画视图的ViewController

动画类型

  • fromLeft
  • fromRight
  • 从顶部
  • 从底部
  • 弹出进入
  • 弹出退出
  • 抖动
  • 按钮点击
动画名称 示例 动画名称 示例
fromLeft fromLeft 从顶部 fromTop
fromRight fromRight 从底部 fromBottom
弹出进入 popIn 弹出退出 popOut
抖动 shake 按钮点击 buttonTap

单元格动画

展示示例代码

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.") }
        }
    }

动画类型

  • 透明度
  • 波浪
  • 从左到右
  • 从上到下
  • 弹跳
  • 从右到左
  • 旋转
  • 线性
  • 缩放
  • 卡片下落
  • 从右侧拖动
动画名称 示例 动画名称 示例
透明度 alpha 波浪 wave
从左到右 leftToRight 从上到下 topToBottom
弹跳 bounce 从右到左 rightToLeft
旋转 rotate 线性 linear
缩放 zoom 卡片下落 cardDrop
从右侧拖动 dragFromRight