In the recent tutorials, it has been underlined that iOS 7 has brought along great new features. Many new frameworks, libraries and APIs have been exposed to developers, letting them create modern and engaging applications and attract more users. One of them is the UIKit Dynamics library, integrated right into the UIKit framework, allowing the implementation of real physics in the most simple manner ever possible.
UIKit Dynamics is a brand new library shipped in iOS 7, and to those who haven’t used it or ever read about it, it might sounds hard to work with. However, the truth is totally different, and through this tutorial I’ll make an effort to present how easy it has been done to add realism to an app without having deep knowledge of physics, math and of course libraries or frameworks like Core Animation. People who have already worked with such technologies, they’ll find UIKit Dynamics a really handy tool, as it takes away all the hassle and effort that was just described.
Before we proceed in the details of the tutorial, let’s get to know some necessary stuff of the UIKit Dynamics, and let’s meet some of its most important classes that always play significant role when implementing it. So, let me start by saying that by being the UIKit Dynamics part of the UIKit framework, there’s no need to add any extra framework in order to use it. It’s always there, ready to be used at any time when the UIKit is imported into a project. It can be applied to any UIView object, or a subclass of it (such as UIButton or UILabel). The heart of this library is the UIDynamicAnimator class, and behind it there is hidden a physics engine, implemented and built right into the UIKit framework. It is responsible for producing the animation that will attach all the desired realistic effects to an app. However, even though the UIDynamicAnimator class is the core of the UIKit Dynamics, it doesn’t do anything on its own. Objects of some other classes must be added to it, named behaviors, or programmatically speaking, UIDynamicBehaviors. A UIKit Dynamics behavior actually represents a physical behavior of the real world in the programming world, and it specifies the realistic effects provided by UIKit Dynamics to developers. The classes related to behaviors, along with a short description, are the following: