GithubHelp home page GithubHelp logo

tiger6688 / coregraphicsdynamicanimation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from larsacus/coregraphicsdynamicanimation

0.0 2.0 0.0 125 KB

Dynamic drawRect: animation using CoreAnimation for interpolation.

Objective-C 100.00%

coregraphicsdynamicanimation's Introduction

#The What A neat sample project for dynamically animating in CoreAnimation anything drawn in drawRect: using CoreGraphics.

#The How Using some hand-waving, documentation reading, and internet browsing, I've distilled the steps required for this method to work down into the following recipe:

You'll find the following recipe documented in-context in the TOLLightLayer.m class:

  1. @dynamic <property_name> - Let CoreAnimation generate the properties accessors at runtime for our animatable properties.
  2. initWithLayer: - Let CoreAnimation make multiple copies of this layer to use as the presentation layer. Similar to a copyWithZone: implementation. Many layer copies are used for presentation interpolation.
  3. needsDisplayForKey: - Tells CoreAnimation we need to re-draw for our custom animatable property when it is "changed" (always YES for now -- whether or not always returning YES is necessary or if it can be conditional).
  4. actionForKey: - Return an explicit animation (action) for our custom attribute so that CoreAnimation has something to interpolate. Animation curve, timing, etc all have an effect on how many times drawRect: is called.
  5. drawInContext: - Draw your stuff based on parameters (properties) that this layer accepts as input and that has been parameterized in the above method implementations.
  6. Profit?

@theonlylars

coregraphicsdynamicanimation's People

Contributors

larsacus avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.