DZAnimatedGift
示例
要运行示例项目,先克隆存储库,然后从 Example 目录中运行 pod install
需求
XCode
安装
DZAnimatedGift 可以通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中
pod 'DZAnimatedGift'
样本
首先,导入框架
import DZAnimatedGift
简单
在屏幕上添加一张图片,使用默认队列
DZAnimatedGift.addGift(image: "heart_pink",
at: CGPoint(x:sender.frame.midX, y:sender.frame.midY),
absolutePath: points,
duration: drand48()+2.0);
或者
DZAnimatedGift.addGift(image: "heart_pink",
at: CGPoint(x:sender.frame.midX, y:sender.frame.midY),
relativePath: points,
duration: drand48()+2.0);
或者
DZAnimatedGift.addGift(image: String,
at: CGPoint,
path: [PathNode],
type: .relative/.absolute,
duration: drand48()+2.0)
关于参数
image: String // the image of gift
at: CGPoint // start point of the animation
absolutePath: [PathNode] // path of the animation(absolute in view)
relativePath: [PathNode] // path of the animation(relative of the start point)
duration: CGFloat // duration of the animation
struct PathNode
PathNode
var point: CGPoint! // point
var controlPoint: CGPoint? // control point
复杂
let queue = DZAnimatedGift.createQueue(name: "QueueName", inView: self.view);
let width = 64*[0.6, 0.8, 1.0, 1.2].random();
let duration = 1.5*[0.7, 0.8, 0.9, 1.0, 1.2].random();
let g = GiftObject(image: "heart_pink",
startPoint: startPoint,
path: points,
duration: duration,
relative: true,
size: CGSize(width: width, height: width));
queue.add(object: g);
作者
darkzero, [email protected] iOS开发者,在东京/上海工作
许可协议
DZAnimatedGift遵循MIT许可协议。更多信息请参阅LICENSE文件。