Cover Flow-Style Album Flipping

Chapter 5 covered Layer Kit transformations, which allow a layer to be rotates, scaled, and transformed in many other ways. Layer Kit is the foundation for Apple's Cover Flow technology, which is used in selecting albums from the iPod application while in landscape mode.

Layton Duncan of Polar Bear Farm, a software designer for the iPhone, has graciously provided code adapting Apple's CovertFlow example (from XCode tools' examples) to the iPhone. The application's source and images can be downloaded in their entirety at the Polar Bear Farm web site, http://www.polarbearfarm.com.

We've spiced up Layton's example a bit to use the iPhone's photo album as the album covers. So be sure to snap a few photos with your iPhone before trying this example.

To compile this example, use the tool chain on the command line as follows:

$ arm-apple-darwin-gcc -o CovertFlow CovertFlow.m -lobjc \
  -framework CoreFoundation -framework Foundation -framework UIKit \
  -framework LayerKit -framework CoreGraphics \
  -framework GraphicsServices

Example A-4 and Example A-5 contain the code.

Example A-4. LayerKit album example (CovertFlow.h)

#import <Foundation/Foundation.h> #import <CoreFoundation/CoreFoundation.h> #import <UIKit/UIKit.h> #import <UIKit/UIApplication.h> #import <UIKit/UIScroller.h> #import <UIKit/UIView-Hierarchy.h> #import <LayerKit/LayerKit.h> #import <LayerKit/LKScrollLayer.h> #import <GraphicsServices/GraphicsServices.h> /* Number of pixels scrolled before next ...

Get iPhone Open Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.