Bouncing with a CAKeyframeAnimation

For practice with CAKeyframeAnimation, you are going to make the time label grow and shrink to give it a bouncing effect (Figure 23.7).

Figure 23.7  Current time mid-bounce

Current time mid-bounce

Declare a new method in TimeViewController.h.

-​ ​(​v​o​i​d​)​b​o​u​n​c​e​T​i​m​e​L​a​b​e​l​;​

In TimeViewController.m, replace the code that spins the label in showCurrentTime: with a call to bounceTimeLabel.

-​ ​(​I​B​A​c​t​i​o​n​)​s​h​o​w​C​u​r​r​e​n​t​T​i​m​e​:​(​i​d​)​s​e​n​d​e​r​ {​ ​ ​ ​ ​N​S​D​a​t​e​ ​*​n​o​w​ ​=​ ​[​N​S​D​a​t​e​ ​d​a​t​e​]​;​ ​ ​ ​ ​s​t​a​t​i​c​ ​N​S​D​a​t​e​F​o​r​m​a​t​t​e​r​ ​*​f​o​r​m​a​t​t​e​r​ ​=​ ​n​i​l​;​ ...

Get iOS Programming: The Big Nerd Ranch Guide 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.