SlideShare a Scribd company logo
Crafting Interactions
with Core Animation
David Ortinau
@davidortinau
http://davidortinau.com
17 yrs web, desktop, interactive, mobile.
BA English,
Maryville University
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Let’s Talk About
Animation
Architecture of Core Animation
Implicit Animations and Explicit Animations
Tweening!
Real World Use Cases
•
•
•
•
•
Animation?
http://www.nestmagazine.es/2012/04/entrevista-kyle-bean.html
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Interaction Design (IxD) defines the structure and
behavior of interactive systems.
Interaction Designers strive to create meaningful
relationships between people and the products and
services that they use, from computers to mobile
devices to appliances and beyond.
Bill Moggridge’s 3 Questions
How do you do?
How do you feel?
How do you know?
1.
2.
3.
Core Animation Makes it Easy
UIView.Animate (
duration: 4,
animation: () => {
notification.Frame = new RectangleF (new
PointF (0, 0), notification.Frame.Size);
}
);
Architecture
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004514
UIKit /
AppKit
OpenGL ES / Open
GL
Graphics Hardware
Core
Animation
Core Graphics
CAAnimation
CAGroupAnimation
CAPropertyAnimation
CABasicAnimation
CAKeyframeAnimation
CATransition
CALayer
addSubLayer
insertSubLayer
setNeedsDisplay
setNeedsLayout
Every UIView has a CALayer
UIViews are responsible for interactions
CALayers are responsible for what you see
•
•
UIView someView = new UIView();
someView.LayerLayer.Frame = new RectangleF(0, 0, 100, 100);
What you see is a compositing of layers
UIView
CALayer
UIView
UIView
UIImage
UILabel
UIButton
UIButton
UIButton
UIButton
UIButton
UIButton
UIView
CALayer
UIView
UIButton
UIButton
UIButton
UIButton
UIButton
UIButton
UIView
UIImage
UILabel
CALayer
Every UIView has a layer and sets itself as the delegate for that layer
CALayer manages visual content and the geometry of that content
drawRect creates the layer
•
•
•
https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html
CALayer someLayer = new CALayer();
someLayer.Frame = new RectangleF(0, 0, 300, 40);
someLayer.Contents = UIImage.FromFile('path/to/image.png').CGImage;
Layer Geometry
https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html
x
y
+
Bounds
AnchorPoint
Bounds - CGRect
Position - CGPoint
AnchorPoint - CGPoint
Transform-CATransform3D
•
•
•
•
What Core Animation Provides
Interpolation
Timing
Hardware Accelerated. Animations happen on the GPU.
Animations are on a background thread
•
•
•
•
CALayer Hierarchy
CAShapeLayer
CATileLayer
CATextLayer
CAScrollLayer
CAReplicatorLayer
•
•
•
•
•
https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html
Animation Rendering
Layout is on the CPU. Keep visuals flat for better performance.
Animation is on the GPU.
•
•
WWDC Session 238 iOS App Performance: Graphics and Animations
1. Create animation and update view hierarchy
2. Prepare and commit
animation
3. Render each frame
Implicit Animations
Implicit Animations of Layer-Backed Views
Uses default timing and animation properties
UIView must be wrapped in an Animate block
UIView Properties
Frame
Center
BackgroundColor
Opacity
•
•
•
•
•
•
•
Notifications Demo
Animate Block
UIView.Animate (
duration: 4,
delay: 0,
options: UIViewAnimationOptions.CurveEaseIn,
animation: () => {
notification.Frame = new RectangleF
(new PointF (0, 0), notification.Frame.Size);
} ,
completion: null
);
UIViewAnimationOptions
AllowUserInteraction
Autoreverse
CurveLinear, CurveEaseIn, CurveEaseOut, CurveEaseInEaseOut
Repeat
•
•
•
•
UIViewAnimationOptions
Easing is the pace of the animation over time•
Glow Pulse Demo
UIView.Animate(
duration: 1,
delay: 0,
options: UIViewAnimationOptions.Autoreverse |
UIViewAnimationOptions.Repeat,
animation: ()=>{
glow.Alpha = 1;
} ,
completion: null
);
Explicit Animations
Explicit Animations
CABasicAnimation, CAGroupAnimation, CAKeyframeAnimation
More fine grain control of the animation
Only works on the Layer and doesn’t update the View
FillMode = CAFillMode.Forwards
RemovedOnCompletion = false
Sequence animations
Custom animation of your own properties
•
•
•
•
•
•
•
CABasicAnimation
KeyPath - the property to animate
BeginTime - when in time to start, can be used to stagger
sequenced animations
Duration - how long the animation should take, scaled to the
timeline of the parent
From / To
RemoveOnCompletion, FillMode
AnimationStopped, AnimationStarted
TimingFunction - Linear, EaseIn, EaseOut, EaseInEaseOut
•
•
•
•
•
•
•
Attraction Loop Demo
Flow
createSlide() - adds or updates CALayer with new images
transitionIn() - clears old animations, defines new animations, adds them to
layers, Timer calls transitionOut
transitionOut() - defines out animations, adds to layers, AnimationStopped
signals end
cyclesSlides() - increments slide and restarts the loop calling createSlide
CABasicAnimation
titleImage.RemoveAllAnimations();
var localMediaTime = CAAnimation.CurrentMediaTime();
var titleAnim = CABasicAnimation.FromKeyPath("position.x");
titleAnim.Duration = 1;
titleAnim.BeginTime = localMediaTime;
titleAnim.From = NSNumber.FromFloat ( 768f );
titleAnim.To = NSNumber.FromFloat ( View.Frame.Width * 0.5f );
titleAnim.RemovedOnCompletion = false;
titleAnim.FillMode = CAFillMode.Forwards;
titleAnim.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseOut);
titleImage.AddAnimation ( titleAnim, "position.x" );
timer = new System.Timers.Timer ();
timer.Interval = 5000;
timer.Elapsed += (object sender, ElapsedEventArgs e) => {
timer.Stop();
InvokeOnMainThread(()=>{
transitionOut();
} );
} ;
timer.Start();
Everyone Wants to Spin
var spinAnim = new CABasicAnimation {
KeyPath = "transform.rotation.z",
To = NSNumber.FromDouble( Math.PI ),
Duration = 0.4,
Cumulative = true,
RepeatCount = 999
} ;
spinner.Layer.AddAnimation( spinAnim,
"spinMeRightRoundBabyRightRound" );
CAKeyframeAnimation
Animate along a path
Set keyframes for very fine control of the timing
Properties
Path - a bezier curve to follow
KeyTimes - 1:1 with values, from 0 to 1 over duration
Values - the keyframe values at each point
•
•
•
•
•
•
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Infographic Demo
PaintCode, DrawScript
CAKeyframeAnimation
void animateDot () {
CAKeyFrameAnimation keyFrameAnimation = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath ("position");
keyFrameAnimation.Path = animationPath.CGPath;
keyFrameAnimation.Duration = 10;
keyFrameAnimation.CalculationMode = CAKeyFrameAnimation.AnimationPaced;
keyFrameAnimation.FillMode = CAFillMode.Forwards;
keyFrameAnimation.TimingFunction = CAMediaTimingFunction.FromName
(CAMediaTimingFunction.Linear);
dot.AddAnimation (keyFrameAnimation, "MoveImage");
dot.Position = new PointF (222, 326);
}
Easing Tweens
Remember This?
http://www.robertpenner.com/easing/
Bounce Demo
Generating Keyframe Values for Easing Equations
No need to specify KeyTimes as keyframes will be dispersed evenly•
public static float EaseOutBounce(float t, float start, float length)
{
if ((t) < (1 / 2.75f))
{
return length * (7.5625f * t * t) + start;
}
else if (t < (2 / 2.75))
{
return length * (7.5625f * (t -= (1.5f / 2.75f)) * t + .75f) + start;
}
else if (t < (2.5 / 2.75))
{
return length * (7.5625f * (t -= (2.25f / 2.75f)) * t + .9375f) + start;
}
else
{
return length * (7.5625f * (t -= (2.625f / 2.75f)) * t + .984375f) + start;
}
}
http://github.com/debreuil/Swf2XNA, , http://www.robertpenner.com/easing/
TweenBuilder
public static NSObject[] CreateKeyValues (float fromValue, float toValue, EasingFormula easingFormula, int
steps = 100)
{
NSObject[] values = new NSObject[steps];
double value = 0;
float curTime = 0;
for (int t = 0; t < steps; t++) {
curTime = (float)t / (float)steps;
var easingFactor = easingFormula(curTime, 0, 1);
value = (toValue - fromValue) * easingFactor + fromValue;
values[t] = NSNumber.FromDouble(value);
}
return values;
}
Using Keyframe Easing Functions
var localMediaTime = CAAnimation.CurrentMediaTime();
NSObject[] keyframes = TweenBuilder.CreateKeyValues(-295, 0, Easing.EaseOutBounce);
var homeIn = new CAKeyFrameAnimation {
KeyPath = "position.x",
Duration = 1.4,
BeginTime = localMediaTime,
FillMode = CAFillMode.Forwards,
RemovedOnCompletion = false,
TimingFunction = CAMediaTimingFunction.FromName(
CAMediaTimingFunction.Linear ),
Values = keyframes
};
navHome.AddAnimation( homeIn, "homeIn" );
If You Can’t Animate It, Fake It
Resources
Resources
WWDC 2010
Core Animation In Practice
https://developer.apple.com/videos/wwdc/2010/?id=424
https://developer.apple.com/videos/wwdc/2010/?id=425
WWDC 2011 - Core Animation Essentials
https://developer.apple.com/videos/wwdc/2011/?id=421
WWDC 2012 - iOS App Performance: Graphics and Animation
https://developer.apple.com/videos/wwdc/2012/?id=238
Delighting Your Users With Core Animation - Frank Krueger
http://www.youtube.com/watch?v=6JePwHjVj6U&noredirect=1
http://www.slideshare.net/Xamarin/delight-your-users-with-coreanimation
About Core Animation
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html
Robert Penners Easing Functions
http://www.robertpenner.com/easing/
Robin Debreuil’s Swf2XNA Respository
http://github.com/debreuil/Swf2XNA
•
•
•
•
•
•
•
If We Have Time
How to interact with UIView during animation. Notification demo.
How to kill an animation. Attraction Loop demo.
•
•
Thanks!
@davidortinau
http://davidortinau.com
dave@davidortinau.com

More Related Content

PPTX
Task 3 investigating animation techniques
PPTX
The Animation Process
DOCX
Animation
PPTX
Animation
PPT
Animation
PPT
Animation
DOCX
Evaluation of Types of Animation
PPTX
Animations & swift
Task 3 investigating animation techniques
The Animation Process
Animation
Animation
Animation
Animation
Evaluation of Types of Animation
Animations & swift

What's hot (19)

KEY
Animation in iOS
PDF
FMX2013: Butterfly Effect
PPTX
Multimedia animation basic concepts
PPTX
Computer Generated Graphics
PPT
Lec28 29 30 animation
PPT
Animation
PPTX
3D animation film making
PPT
Lecture 9 animation
PDF
Animation basics
PDF
3D Animation Process and Workflow
PPTX
Animation
PPT
3D Animation - A Case Study by Seamedu Media School
PPTX
Animation Film Production Pipeline By : animationgossips.com (Jayant Sharma)
PDF
Animate The Web With Ember.js - Jessica Jordan
PDF
Core Animation
PPTX
Types of animation
PPT
PDF
VFX-An Overview
Animation in iOS
FMX2013: Butterfly Effect
Multimedia animation basic concepts
Computer Generated Graphics
Lec28 29 30 animation
Animation
3D animation film making
Lecture 9 animation
Animation basics
3D Animation Process and Workflow
Animation
3D Animation - A Case Study by Seamedu Media School
Animation Film Production Pipeline By : animationgossips.com (Jayant Sharma)
Animate The Web With Ember.js - Jessica Jordan
Core Animation
Types of animation
VFX-An Overview
Ad

Similar to Crafting interactions with Core Animations, David Ortinau (20)

PDF
Starting Core Animation
PDF
Building animated UI with Core Animation
PDF
animations
PDF
A short guide to animations in iOS
PDF
Core Animation
PDF
iOS Core Animation
PDF
UIKit Dynamics
PPTX
Apps in a Flash HCI
PDF
Animating the UI - Angie Terrell
PPT
Animation
PPS
Learning flash by Ms. Payal Narula
PDF
UI Dynamics
PPTX
Flash
PPT
Animation
PPT
Unit vi
KEY
iOSインタラクションデザイン
PPT
Animation
PDF
Quick Step by Step Flash Tutorial
PPTX
Multimedia Animation, Introduction, History, Types
Starting Core Animation
Building animated UI with Core Animation
animations
A short guide to animations in iOS
Core Animation
iOS Core Animation
UIKit Dynamics
Apps in a Flash HCI
Animating the UI - Angie Terrell
Animation
Learning flash by Ms. Payal Narula
UI Dynamics
Flash
Animation
Unit vi
iOSインタラクションデザイン
Animation
Quick Step by Step Flash Tutorial
Multimedia Animation, Introduction, History, Types
Ad

More from Xamarin (20)

PDF
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
PDF
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
PDF
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
PDF
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
PDF
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
PDF
Build Better Games with Unity and Microsoft Azure
PDF
Exploring UrhoSharp 3D with Xamarin Workbooks
PDF
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
PDF
Developer’s Intro to Azure Machine Learning
PDF
Customizing Xamarin.Forms UI
PDF
Session 4 - Xamarin Partner Program, Events and Resources
PDF
Session 3 - Driving Mobile Growth and Profitability
PDF
Session 2 - Emerging Technologies in your Mobile Practice
PDF
Session 1 - Transformative Opportunities in Mobile and Cloud
PDF
SkiaSharp Graphics for Xamarin.Forms
PDF
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
PDF
Intro to Xamarin.Forms for Visual Studio 2017
PDF
Connected Mobile Apps with Microsoft Azure
PDF
Introduction to Xamarin for Visual Studio 2017
PDF
Building Your First iOS App with Xamarin for Visual Studio
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Build Better Games with Unity and Microsoft Azure
Exploring UrhoSharp 3D with Xamarin Workbooks
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Developer’s Intro to Azure Machine Learning
Customizing Xamarin.Forms UI
Session 4 - Xamarin Partner Program, Events and Resources
Session 3 - Driving Mobile Growth and Profitability
Session 2 - Emerging Technologies in your Mobile Practice
Session 1 - Transformative Opportunities in Mobile and Cloud
SkiaSharp Graphics for Xamarin.Forms
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Intro to Xamarin.Forms for Visual Studio 2017
Connected Mobile Apps with Microsoft Azure
Introduction to Xamarin for Visual Studio 2017
Building Your First iOS App with Xamarin for Visual Studio

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Big Data Technologies - Introduction.pptx
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
sap open course for s4hana steps from ECC to s4
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Cloud computing and distributed systems.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MIND Revenue Release Quarter 2 2025 Press Release
Big Data Technologies - Introduction.pptx
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine Learning_overview_presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
Building Integrated photovoltaic BIPV_UPV.pdf
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine learning based COVID-19 study performance prediction
sap open course for s4hana steps from ECC to s4
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Cloud computing and distributed systems.

Crafting interactions with Core Animations, David Ortinau