Saturday 11 August 2012

Core Animation for Mac OS X and the iPhone


Core Animation for Mac OS X and the iPhone Creating Compelling Dynamic User Interfaces
Bill Dudney

Core Animation became part of Mac OS X in Leopard (10.5) and is inte- grated into the rest of Cocoa so that you can use the features without having to learn a whole new paradigm of user interface design and building. In fact, you can get most of the benefits and features of Core Animation without having to leave the comfortable world of AppKit view- based user interface programming. During the first several chapters of this book, we will focus on what we can do with Core Animation with the tight integration of AppKit. Then, in the later chapters, we will focus on the features that we can create when we move to a purely Core Animation–based user interface.
Chapter 2, Cocoa Animation, on page 17 begins our journey into ani- mated applications with a discussion of what is possible using only Cocoa APIs. The flow of the book takes you from familiar concepts in AppKit and slowly introduces the additional APIs that are part of the Core Animation framework. The chapters start with pure AppKit ani- mation and then introduce the Core Animation APIs that are directly integrated into the AppKit. Finally, the book discusses the additional features we gain by using a “pure” Core Animation layer-based UI. The gradual introduction has two purposes. The first motivation is to transi- tion from known concepts into the unknown by tying together concepts that are familiar and showing the unfamiliar in terms of the familiar. The second motivation is to show you what is possible without having to learn the whole Core Animation framework. For example, it is amaz- ing how much is possible by simply turning on layer backing. Simply by calling one method, we can gain a huge amount of animation power, and we don’t even have to really learn Core Animation. We can gradu- ally move into it as the need arises instead of having to wrap our heads around a whole new framework just to get started.

I don’t want to give the impression, however, that Core Animation is hard to learn. It’s actually quite easy to pick up once you learn a few basic concepts. And although a lot of animation is possible in the Cocoa APIs, we gain a lot of flexibility and features as we start to use the Core Animation APIs. Chapter 3, Animation Types, on page 28 introduces the various types of animations that are available in the Core Animation framework.
Next up, Chapter 4, Animation Timing, on page 45 discusses the Core Animation classes related to controlling the timing of the animations that we use. Both of these chapters take an AppKit-centric approach to the material, and the examples are purely view-based. Again, this is to make the transition gradual. Once learned, though, the concepts are transferable directly to Core Animation layer-based animations.
Chapter 5, Layer-Backed Views, on page 58 discusses the new features we gain by turning on layer backing for our views. In this chapter, we begin to see some of the features that are possible with Core Anima- tion layers, but again we stay mostly focused on the AppKit-centric view of things. But we are beginning our transition into a more Core Animation–focused user interface.
In Chapter 6, Filtered Views, on page 68, we see Core Image filters in action (Core Image is Apple’s way of doing image processing on the GPU). Specifically, we will see how to apply any one of the dozens of Core Image filters that are available to our views. This chapter com- pletes the look at what is possible with the Core Animation and AppKit integration. The next chapter (Chapter 7, Core Animation, on page 81) covers Core Animation–based user interfaces and the layer tree.
In Chapter 8, Core Animation Layers, on page 96, we see the way we would apply what we’ve already learned about Core Animation classes (in Chapter 3, Animation Types, on page 28; Chapter 4, Animation Tim- ing, on page 45; Chapter 5, Layer-Backed Views, on page 58; and Chap- ter 6, Filtered Views, on page 68) and then apply this knowledge to lay- ers. The chapter covers how layers work and what they have been doing for us in the previous chapters without us having to think about it.
In Chapter 9, Layer Scrolling and Geometry, on page 118, we explore the geometry of layers and see how to scroll them. You will learn the similarities and differences between the way AppKit scrolls views and be able to apply what you already know to learning layer scrolling.

In Chapter 10, Layers in 3D, on page 133, we explore how to animate layers in 3D, including building our own custom layer manager and making that take care of the heavy lifting for us so that our application and layer manipulation code can remain simple.
Next up, in Chapter 11, Media Layers, on page 149, we explore how to use various media types in a mixed UI based on layers. Core Animation allows us to mix and match media content of various types freely. For example, we can have a QuickTime movie playing in the same view as an OpenGL animation and place a Quartz Composer composition in the background. This mix-and-match approach opens many UI avenues that were just not possible before Core Animation.
Finally, the book ends by covering Core Animation for the iPhone (Chapter 12, Core Animation on the iPhone, on page 165). In this final chapter, we cover the various differences between developing for the iPhone and developing for Mac OS X. The good thing is that Core Animation is for the most part the same on the iPhone, so all the stuff you’ve learned applies with just a few caveats. This final chapter explains those caveats and teaches you some additional tricks about doing Core Animation on the iPhone.
Once you are done reading this book, there many Apple publications that you’ll find helpful. Start with Apple’s “Introduction to Core Anima- tion Programming Guide” [App08a]. You’ll next want to learn more in general about Core Image from the “Introduction to Core Image Pro- gramming Guide” [App08b]. Read more about the effects you can add to your animations in their “Introduction to Quartz Composer User Guide” [App07b]. You’ll learn about working with 3D animations in the “OpenGL Programming Guide for Mac OS X” [App08c]. If you’re stick- ing with two dimensions you’ll enjoy the “Introduction to Quartz 2D Programming Guide” [App07a]. Finally, you can improve on your per- formance by reading the “Cocoa Drawing Tips” [App06].

Download Here



No comments:

Post a Comment