CoreAnimation layers are full of Traps
Apple's beautifull SDK includes the nice and easy CoreAnimation API. CoreAnimation can be used for animating just about anything you can display on the screen. CoreAnimation appears to be an easy to use wrapper for OpenGL(ES). Well, basically anything you draw on the screen of an iPhone appears underneath to be handled by OpenGL(ES). CoreAnimation makes all those nifty display effects (fades, rotations, wiggles, etc.) really quick and comfortably to implement. And the way that works is definitely super close to what you do when animating directly via OpenGL(ES) - a fact that makes the transition from CoreAnimation towards OpenGL(ES) very straightforward in case you ever need to go that extra step.
BUT, be warned, there are drawbacks in CoreAnimation that are not really obvious in the first place.
CoreAnimation works on so called layers (CALayer). Those layers are compareable to a Canvas in HTML5. Such layer may have children (sublayers) resulting into a tree structure.
Actions such as rotation, translation and scaling on a layer automatically affect its sublayers. That is not a trap but a great feature. However, when animating such actions, I found the first trap that really was annoying. When animating a rotation around some abritary point, you need to translate the layers' anchor point (origin) towards that custom point, rotate and reverse the translation again. This is common and done the exact same way when using OpenGL(ES). Trouble is, when doing all of that in an animation (CABAnimation), CoreAnimation will basically interpolate all the changes you do between the given start and end status. That will include your translation towards the custom point you intend to rotate around. As a result, you will see the rotation is done around a moving point - something you wont really expect or desire. I have not found a proper solution for that issue and learned to live with it. Still, I think there might be solitions, just I was too dumb to find em until today. So that was trap number one.
Trap number two is connected to three dimensional rendering... I needed to have two objects, each of them with plenty of sublayers displayed. Trouble came when I needed them to intersect each other with partial hiding. A CALayer can be translated with CoreAnimation into all three dimensions. Additionally a CALayer has a property called zPosition. Equipped with that knowledge I assumed that it should be a no-brainer to have a partial intersection with partial hiding. I guess I was wrong :). Turns out that CoreAnimation, even though it has all those attributes (z-coordinate through translation and z-position property) does not allow partial hiding of sublayers using the third dimension. The reason for that is that a all sublayers of a toplayer are, in the end, rendered onto the same layer. The zPosition (CALayer property) is only usefull for giving a display order of toplayers. The z-coordinate (CoreAnimation translate) is only used for perspectivic skewing. None of those attributes helps when you intend to achieve partial hiding of intersecting sublayers of two (or more) toplayers. As a consequence, whenever you need "proper" 3D, dont use CoreAnimation but immediately go to OpenGL(ES) - or, use foul workarounds with manual interventions.