Grokking the Default Core Animation Transitions
In the tradition of my last grokking post (but hopefully without the memory mgt problems :) I have another example that just did not fit into the flow of the book but I think it makes a great app to experiment with.
This app will let you choose from the four different default transition types and then add and remove an image layer so you can see how each of the transition types behaves. It uses bindings to get the content for the pull downs and to know if the subtypes should be hidden or not. Its not the best example in the world though for grokking bindings, if you want/need to know more about bindings go check out Scott's tutorial.
Interesting stuff about the example;
- some transitions only work on the change from hidden == NO to hidden == YES
- some only work when hidden changes from YES to NO
- the snowman is a pic we shot at last years snow carving competition in Breckenridge.
There are of course a hundred ways to make this kind of thing happen. In this example the transitions are invoked when the 'hidden' property is changed. You could achieve the same effect via delegation and providing an animation for kCAOnOrderIn or kCAOnOrderOut. But hidden makes the code smaller if less flexible.
You might notice on the 'fade' transition when you hit remove that the rounded corners dissapear. I'm not sure if that is a bug or something wrong in my code. I have submitted a bug to Apple.
Here is a screen shot of the app.
And here is the code.
Permalink Add A CommentNew Beta Available
We pushed a new beta today. Most of the existing errata was addressed as well as adding a new chapter 'Core Animation' in which you will learn all about layer hosting views and building UI's with CA.
Permalink Add A Comment





