Graphics Reference
In-Depth Information
LISTING 1-1
Continued
if ( scaleUp )
{
// Scale everything (x, y, and z) by a factor of
// factor (static variable) and reduce the opacity
CATransform3D transform = CATransform3DMakeScale(factor,
factor,
factor);
[mainLayer setTransform:transform];
mainLayer.opacity = 0.0f;
scaleUp = NO ;
}
else
{
// Scale the rect back down to the original and bring up
// the opacity
CATransform3D transform = CATransform3DMakeScale(1.0f,
1.0f,
1.0f);
[mainLayer setTransform:transform];
mainLayer.opacity = 1.0f;
scaleUp = YES ;
}
}
Listing 1-1 shows only the transform of the main parent layer. Adding the child layers is
fairly simple, and we have provided the code from that blog post as a resource for this
chapter, so take a look at it to see the
complete code and how to implement
this effect.
NOTE
The sample project that demonstrates this
effect is called, simply, Dashboard Effect.
For many people, using more complex
mathematics is daunting, but again, as
part of your free lunch from Apple, you
don't need to know much in the way of mathematics to effectively use Core Animation.
Basic arithmetic is really all you need to know. It is that simple.
Core Animation and the iPhone
You might be reading this topic because you want to use Core Animation for an iPhone
app you're working on. We have dedicated an entire chapter to using Core Animation on
the iPhone to help you understand some of the basic differences. The differences are
small, and often you can use the exact same code on the iPhone that you would use on
 
 
Search WWH ::




Custom Search