-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASAnimations.swift
56 lines (45 loc) · 1.74 KB
/
ASAnimations.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// ASAnimations.swift
// AnimationSequencer
//
// Created by Fabio Nisci on 10/03/2020.
//
import UIKit
public extension ASSequence {
static func fadeTo(_ value:CGFloat, duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) { $0.alpha = value }
}
static func fadeIn(duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) { $0.alpha = 1 }
}
static func fadeOut(duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) { $0.alpha = 0 }
}
static func resize(boundsTo size: CGSize, duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) { $0.bounds.size = size }
}
static func resize(frameTo size: CGSize, duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) { $0.frame.size = size }
}
static func move(byX x: CGFloat, y: CGFloat, duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) {
$0.center.x += x
$0.center.y += y
}
}
static func move(toX x: CGFloat, y: CGFloat, duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) {
$0.frame.origin.x = x
$0.frame.origin.y = y
}
}
static func move(centerToX x: CGFloat, y: CGFloat, duration: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: duration) {
$0.center.x = x
$0.center.y = y
}
}
func delayedFor(_ delay: TimeInterval = 0.3) -> ASSequence {
return ASSequence(duration: self.duration, delay: delay, animation: self.animation)
}
}