Cover by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

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​;​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required