Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Easy Animation at Cocoaheads Copenhagen
Marin Todorov
October 04, 2015
Technology
3
200
Easy Animation at Cocoaheads Copenhagen
Slides from the Easy Animation talk at Cocoaheads Copenhagen
Marin Todorov
October 04, 2015
Tweet
Share
More Decks by Marin Todorov
See All by Marin Todorov
icanzilb
0
310
icanzilb
4
3.4k
icanzilb
3
21k
icanzilb
3
610
icanzilb
1
290
icanzilb
1
2.4k
icanzilb
1
130
icanzilb
1
880
Other Decks in Technology
See All in Technology
kyonmm
1
1.9k
harshbothra
0
100
minamizaki
0
540
hamadakoji
0
1.1k
zaki134rp
1
180
vkbaba
0
110
torisoup
0
270
cygames
1
340
pinboro
1
1.4k
yuyaabo
0
250
soracom
0
250
yuuturn
1
130
Featured
See All Featured
kneath
294
39k
jacobian
255
20k
brettharned
93
3k
sugarenia
233
830k
chrislema
231
16k
tmm1
61
8.3k
keavy
106
14k
jonrohan
1021
380k
destraynor
223
47k
imathis
478
150k
vanstee
116
4.8k
swwweet
206
6.8k
Transcript
Easy Animation Marin Todorov
Swift 2.0 Swift 2.0
None
Motivation
Motivation How would I improve the built-in animation APIs?
Goals * easier layer animations * easier animation sequences *
layer spring animations
David Rönnqvist post on objc.io
UIView.animateWithDuration(1.0, animations: { }) Create an animation context Destroy the
animation context Original animations block Animate layer properties
CALayer() UIView() layer layer view delegate
animations block view.alpha = 0.5 layer.position.y = 200 layer.cornerRadius =
50 UIView.actionForLayer(layer, “alpha”) CAAnimation UIView.actionForLayer(layer, “position.y”) CAAnimation UIView.actionForLayer(layer, “cornerRadius”) NSNull
layer.cornerRadius = 50 CABasicAnimation(keyPath: “cornerRadius”) toValue = 50 fromValue =
<current value>
Layer animations
Goals * easier layer animations * easier animation sequences *
layer spring animations
UIView.animationWithDuration(1.0, animations: { first animation }).animateWithDuration(1.0, { second animation })…
etc …
Sequence animations
Goals * easier layer animations * easier animation sequences *
layer spring animations
UIKit.animateWithDuration(…) CABasicAnimation UIKit.animateWithDuration(… springDamping: , springInitialVelocity: …) CASpringAnimation on iOS9
RBBSpringAnimation on iOS8
Feelings
Gotchas * Premature completion! * What is a damped harmonic
oscillator? * Retain/release #$!
What’s next? UIView.animateWithDuration(1.0, animations: { }) self.myButton.animationPath = CGPath(…) self.myButton.transform.scale.x
= 1.2 self.myButton.rotation = M_PI_4
How bout smth crazy? UIView.animateWithDuration(1.0, animations: { }) self.myButton.center.x =
20 Update the view constraints and thus make this work on AL? Whaaaa?
Marin Todorov Thank you! www.underplot.com