Chapter 14. Applying motion effects and dynamics

 

This chapter covers

  • Motion effects using UIMotionEffects
  • Adding the parallax effect
  • Realistic animations with UIKit Dynamics
  • Simulating gravity, collisions, and elasticity
  • Creating custom behaviors

With iOS 7 came flat textures devoid of gradients and out went skeuomorphic design that mimicked real-life physical objects. There was also the addition of parallax, which made interface objects appear to be three-dimensional by altering their position ever so slightly depending on the angle at which you’re holding your device. This parallax effect and many others can be achieved by using the new motion APIs in UIKit. Also, before iOS 7 you needed to dive into complex math and physics if you wanted to create realistic physics effects in your views. Now there’s also a whole new slew of APIs in UIKit Dynamics that you can use to create these realistic effects without having to be a mathematician. You’ll learn about both motion and dynamics in this chapter. Together we’ll build a fun little app that will serve as a catalog to showcase a few of the great things you can now do.

14.1. Creating your application

The app you’ll prepare for this chapter will be rather quick and simple. It will involve two images, a basketball court floor for the background and an image of a basketball, which we’ll use to demonstrate motion and dynamics. Open Xcode and create a new single-view application called Motion Ball.

14.2. Using motion effects

14.3. Using UIKit Dynamics

14.4. Summary