SlideShare a Scribd company logo
Core Animation
                for iPhone



www.invasivecode.com   1   CocoaHeads, Barcelona, April 24, 2009
What’s that?

              Transforming smoothly an object’s visual
                      representation over time



          Import QuartzCore.framework in your project




www.invasivecode.com             2          CocoaHeads, Barcelona, April 24, 2009
CALayer


         • Every view is layer-backed
         • A cached copy of UIView’s appearance
         • Takes responsibility during animation




www.invasivecode.com           3          CocoaHeads, Barcelona, April 24, 2009
CALayer




www.invasivecode.com      4      CocoaHeads, Barcelona, April 24, 2009
Layer geometry




www.invasivecode.com         5    CocoaHeads, Barcelona, April 24, 2009
Layer transformations
 You can use matrix transformations
 It is a CGFloat 4x4 matrix

 trasform and sublayerTransform
         Function                                                                   Use
 CATranform3DMakeTranslation   Returns a transform that translates by '(tx, ty, tz)'. t' = [1 0 0 0; 0 1 0 0; 0 0 1 0; tx ty tz 1].
 CATranform3DTranslate         Translate 't' by '(tx, ty, tz)' and return the result: * t' = translate(tx, ty, tz) * t.
 CATranform3DMakeScale         Returns a transform that scales by `(sx, sy, sz)': * t' = [sx 0 0 0; 0 sy 0 0; 0 0 sz 0; 0 0 0 1].
 CATranform3DScale             Scale 't' by '(sx, sy, sz)' and return the result: * t' = scale(sx, sy, sz) * t.
                               Returns a transform that rotates by 'angle' radians about the vector '(x, y, z)'. If the vector has
 CATranform3DMakeRotation
                               length zero the identity transform is returned.
                               Rotate 't' by 'angle' radians about the vector '(x, y, z)' and return the result. t' = rotation(angle, x,
 CATranform3DRotate
                               y, z) * t.




www.invasivecode.com                                               6                            CocoaHeads, Barcelona, April 24, 2009
Animation types


         • Implicit animation
         • Explicit animation
         • Key-frame animation



www.invasivecode.com          7    CocoaHeads, Barcelona, April 24, 2009
Implicit animations

    • The simplest type of animation
    • Tell UIView that it should animate and change its
      properties

   The animation starts when commitAnimations is sent
                 [UIView beginAnimations:nil context:nil];

                 // your code here

                 [UIVIew commitAnimations];



www.invasivecode.com                 8           CocoaHeads, Barcelona, April 24, 2009
Implicit animations
      Defined in UIView          + beginAnimations:context:
                                + commitAnimations
                                + setAnimationStartDate:
                                + setAnimationsEnabled:
                                + setAnimationDelegate:
                                + setAnimationWillStartSelector:
                                + setAnimationDidStopSelector:
                                + setAnimationDuration:
                                + setAnimationDelay:
                                + setAnimationCurve:
                                + setAnimationRepeatCount:
                                + setAnimationRepeatAutoreverses:
                                + setAnimationBeginsFromCurrentState:
                                + setAnimationTransition:forView:cache:
                                + areAnimationsEnabled



              All the properties change concurrently

www.invasivecode.com              9              CocoaHeads, Barcelona, April 24, 2009
Explicit animations
     • Basic Animations: CABasicAnimation
     • You can specify the animation for each layer property
     • Create an animation with
       +animationWithKeyPath:
     • Apply the animation sending
       addAnimation:forKey
     • Stop the animation sending:
       removeAnimationForKey:

www.invasivecode.com           10         CocoaHeads, Barcelona, April 24, 2009
Objects
                                  CAAnimation             <CAMediaTiming>




    CAAnimationGroup

                                                          CATransition

                            CAPropertyAnimation




               CABasicAnimation                 CAKeyframeAnimation


www.invasivecode.com                    11             CocoaHeads, Barcelona, April 24, 2009
CAMediaTimingFunction




www.invasivecode.com   12   CocoaHeads, Barcelona, April 24, 2009
View Transitions



www.invasivecode.com   13   CocoaHeads, Barcelona, April 24, 2009
What is it?

      • Special kind of animation


        #import <QuartzCore/CAAnimation.h>
        CATransition *aTransition = [CATransition animation];




www.invasivecode.com             14           CocoaHeads, Barcelona, April 24, 2009
Animation type

                aTransition.type = kCATransitionMoveIn;



         Animation type                        Description
       kCATransitionFade     Fade from one view to the next

       kCATransitionPush     Push the old view out, bringing the new one in

       kCATransitionReveal   Move the old view out revealing the new one

       kCATransitionMoveIn   Move the new view in over the old one




www.invasivecode.com                     15              CocoaHeads, Barcelona, April 24, 2009
Animation subtype

           aTransition.subtype = kCATransitionFromLeft;


                Animation subtype                Description
             kCATransitionFromTop      New views slides from top
             kCATransitionFromBottom   New views slides from bottom

             kCATransitionFromRight    New views slides from right

             kCATransitionFromLeft     New views slides from left




www.invasivecode.com                   16                CocoaHeads, Barcelona, April 24, 2009
Timing and duration

   aTransition.timingFunction = UIViewAnimationCurveEaseIn;

                       Timing                             Description
          UIViewAnimationCurveEaseInOut   Animation is slow at the beginning and the end
          UIViewAnimationCurveEaseIn      Animation speed increase at the beginning
          UIViewAnimationCurveEaseOut     Animation speed decrease at the end
          UIViewAnimationCurveLinear      Uniform speed



                  aTransition.duration = 0.5; // seconds




www.invasivecode.com                          17                   CocoaHeads, Barcelona, April 24, 2009
Animate a view


   [self.view.superview.layer addAnimation:myTransition forKey:nil];




www.invasivecode.com               18           CocoaHeads, Barcelona, April 24, 2009

More Related Content

Similar to Core Animation

Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 week6 scripting_motion
Artdm170 week6 scripting_motionArtdm170 week6 scripting_motion
Artdm170 week6 scripting_motion
Gilbert Guerrero
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JAX London
 
iOS Core Animation
iOS Core AnimationiOS Core Animation
iOS Core Animation
Jussi Pohjolainen
 
Core Animation
Core AnimationCore Animation
Core Animation
Bob McCune
 
Core animation
Core animationCore animation
Core animation
Weizhong Yang
 
UI Dynamics
UI DynamicsUI Dynamics
UI Dynamics
SV.CO
 
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David OrtinauCrafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
Xamarin
 
Optimized Rendering Techniques for Mobile VR
Optimized Rendering Techniques  for Mobile VROptimized Rendering Techniques  for Mobile VR
Optimized Rendering Techniques for Mobile VR
DevGAMM Conference
 
Mapping the world with Twitter
Mapping the world with TwitterMapping the world with Twitter
Mapping the world with Twitter
carlo zapponi
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking framework
Phat VU
 
A practical intro to BabylonJS
A practical intro to BabylonJSA practical intro to BabylonJS
A practical intro to BabylonJS
HansRontheWeb
 
Master of Canvas
Master of CanvasMaster of Canvas
Master of Canvas
Mima Yuki
 
Vue in Motion
Vue in MotionVue in Motion
Vue in Motion
Rachel Nabors
 
Rotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billyRotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billy
nimbleltd
 
Android canvas-chapter20
Android canvas-chapter20Android canvas-chapter20
Android canvas-chapter20
Dr. Ramkumar Lakshminarayanan
 
Eye ball cursor movement using opencv
Eye ball cursor movement using opencvEye ball cursor movement using opencv
Eye ball cursor movement using opencv
Venkat Projects
 
Core animation taobao
Core animation taobaoCore animation taobao
Core animation taobao
yarshure Kong
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
Boxed Ice
 
Animation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIsAnimation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIs
account inactive
 

Similar to Core Animation (20)

Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
Artdm170 week6 scripting_motion
Artdm170 week6 scripting_motionArtdm170 week6 scripting_motion
Artdm170 week6 scripting_motion
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
 
iOS Core Animation
iOS Core AnimationiOS Core Animation
iOS Core Animation
 
Core Animation
Core AnimationCore Animation
Core Animation
 
Core animation
Core animationCore animation
Core animation
 
UI Dynamics
UI DynamicsUI Dynamics
UI Dynamics
 
Crafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David OrtinauCrafting interactions with Core Animations, David Ortinau
Crafting interactions with Core Animations, David Ortinau
 
Optimized Rendering Techniques for Mobile VR
Optimized Rendering Techniques  for Mobile VROptimized Rendering Techniques  for Mobile VR
Optimized Rendering Techniques for Mobile VR
 
Mapping the world with Twitter
Mapping the world with TwitterMapping the world with Twitter
Mapping the world with Twitter
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking framework
 
A practical intro to BabylonJS
A practical intro to BabylonJSA practical intro to BabylonJS
A practical intro to BabylonJS
 
Master of Canvas
Master of CanvasMaster of Canvas
Master of Canvas
 
Vue in Motion
Vue in MotionVue in Motion
Vue in Motion
 
Rotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billyRotoscope inthebrowserppt billy
Rotoscope inthebrowserppt billy
 
Android canvas-chapter20
Android canvas-chapter20Android canvas-chapter20
Android canvas-chapter20
 
Eye ball cursor movement using opencv
Eye ball cursor movement using opencvEye ball cursor movement using opencv
Eye ball cursor movement using opencv
 
Core animation taobao
Core animation taobaoCore animation taobao
Core animation taobao
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
 
Animation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIsAnimation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIs
 

Recently uploaded

GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 

Recently uploaded (20)

GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 

Core Animation

  • 1. Core Animation for iPhone www.invasivecode.com 1 CocoaHeads, Barcelona, April 24, 2009
  • 2. What’s that? Transforming smoothly an object’s visual representation over time Import QuartzCore.framework in your project www.invasivecode.com 2 CocoaHeads, Barcelona, April 24, 2009
  • 3. CALayer • Every view is layer-backed • A cached copy of UIView’s appearance • Takes responsibility during animation www.invasivecode.com 3 CocoaHeads, Barcelona, April 24, 2009
  • 4. CALayer www.invasivecode.com 4 CocoaHeads, Barcelona, April 24, 2009
  • 5. Layer geometry www.invasivecode.com 5 CocoaHeads, Barcelona, April 24, 2009
  • 6. Layer transformations You can use matrix transformations It is a CGFloat 4x4 matrix trasform and sublayerTransform Function Use CATranform3DMakeTranslation Returns a transform that translates by '(tx, ty, tz)'. t' = [1 0 0 0; 0 1 0 0; 0 0 1 0; tx ty tz 1]. CATranform3DTranslate Translate 't' by '(tx, ty, tz)' and return the result: * t' = translate(tx, ty, tz) * t. CATranform3DMakeScale Returns a transform that scales by `(sx, sy, sz)': * t' = [sx 0 0 0; 0 sy 0 0; 0 0 sz 0; 0 0 0 1]. CATranform3DScale Scale 't' by '(sx, sy, sz)' and return the result: * t' = scale(sx, sy, sz) * t. Returns a transform that rotates by 'angle' radians about the vector '(x, y, z)'. If the vector has CATranform3DMakeRotation length zero the identity transform is returned. Rotate 't' by 'angle' radians about the vector '(x, y, z)' and return the result. t' = rotation(angle, x, CATranform3DRotate y, z) * t. www.invasivecode.com 6 CocoaHeads, Barcelona, April 24, 2009
  • 7. Animation types • Implicit animation • Explicit animation • Key-frame animation www.invasivecode.com 7 CocoaHeads, Barcelona, April 24, 2009
  • 8. Implicit animations • The simplest type of animation • Tell UIView that it should animate and change its properties The animation starts when commitAnimations is sent [UIView beginAnimations:nil context:nil]; // your code here [UIVIew commitAnimations]; www.invasivecode.com 8 CocoaHeads, Barcelona, April 24, 2009
  • 9. Implicit animations Defined in UIView + beginAnimations:context: + commitAnimations + setAnimationStartDate: + setAnimationsEnabled: + setAnimationDelegate: + setAnimationWillStartSelector: + setAnimationDidStopSelector: + setAnimationDuration: + setAnimationDelay: + setAnimationCurve: + setAnimationRepeatCount: + setAnimationRepeatAutoreverses: + setAnimationBeginsFromCurrentState: + setAnimationTransition:forView:cache: + areAnimationsEnabled All the properties change concurrently www.invasivecode.com 9 CocoaHeads, Barcelona, April 24, 2009
  • 10. Explicit animations • Basic Animations: CABasicAnimation • You can specify the animation for each layer property • Create an animation with +animationWithKeyPath: • Apply the animation sending addAnimation:forKey • Stop the animation sending: removeAnimationForKey: www.invasivecode.com 10 CocoaHeads, Barcelona, April 24, 2009
  • 11. Objects CAAnimation <CAMediaTiming> CAAnimationGroup CATransition CAPropertyAnimation CABasicAnimation CAKeyframeAnimation www.invasivecode.com 11 CocoaHeads, Barcelona, April 24, 2009
  • 12. CAMediaTimingFunction www.invasivecode.com 12 CocoaHeads, Barcelona, April 24, 2009
  • 13. View Transitions www.invasivecode.com 13 CocoaHeads, Barcelona, April 24, 2009
  • 14. What is it? • Special kind of animation #import <QuartzCore/CAAnimation.h> CATransition *aTransition = [CATransition animation]; www.invasivecode.com 14 CocoaHeads, Barcelona, April 24, 2009
  • 15. Animation type aTransition.type = kCATransitionMoveIn; Animation type Description kCATransitionFade Fade from one view to the next kCATransitionPush Push the old view out, bringing the new one in kCATransitionReveal Move the old view out revealing the new one kCATransitionMoveIn Move the new view in over the old one www.invasivecode.com 15 CocoaHeads, Barcelona, April 24, 2009
  • 16. Animation subtype aTransition.subtype = kCATransitionFromLeft; Animation subtype Description kCATransitionFromTop New views slides from top kCATransitionFromBottom New views slides from bottom kCATransitionFromRight New views slides from right kCATransitionFromLeft New views slides from left www.invasivecode.com 16 CocoaHeads, Barcelona, April 24, 2009
  • 17. Timing and duration aTransition.timingFunction = UIViewAnimationCurveEaseIn; Timing Description UIViewAnimationCurveEaseInOut Animation is slow at the beginning and the end UIViewAnimationCurveEaseIn Animation speed increase at the beginning UIViewAnimationCurveEaseOut Animation speed decrease at the end UIViewAnimationCurveLinear Uniform speed aTransition.duration = 0.5; // seconds www.invasivecode.com 17 CocoaHeads, Barcelona, April 24, 2009
  • 18. Animate a view [self.view.superview.layer addAnimation:myTransition forKey:nil]; www.invasivecode.com 18 CocoaHeads, Barcelona, April 24, 2009