UIKit Dynamics – Part 2 (Collision Detection, Stasis & Avoiding Memory Cycles)

Note, this is part 2 in the UIKit Dynamics tutorials. In part 1 we talked about getting started using UIKit Dynamics. If you’re not familiar with how to animate views using UIDynamicAnimator and how to make use of UIDynamicBehavior subclasses, it’s crucial to take a look first at part 1.
In part 2, we’ll be discussing 3 more topics related to UIKit Dynamics.

  1. Collision detection; how to detect collisions between the different animated views and boundaries.
  2. Stasis; we’ll get to know what’s meant by stasis and how to detect it.
  3. How to avoid memory cycles in your animation code.

Continue reading

UIKit Dynamics Tutorial in Swift 2.0

During the last month, I learned about the awesome UIKit Dynamic animations framework. It’s a physics-based animation and it’s really fun when you use it wisely in your applications. You can add different physics-based behaviors like collisions, bouncing, gravity .. and a lot more behaviors and settings. Today I’ll take you in a quick tour on how to use the framework, and then, we’ll build together a fun demo app that demonstrates the effect of combining different behaviors, also the effect of changing magnitudes and settings of the different behavior.


So, enough talking let’s get our hands dirty!
Continue reading

How to Switch View Controllers using Segmented Control – Swift 3.0

I received this question many times, “How to build Android-like tab bar in iOS?”
Find the answer below:

One of the typical usages of a UISegmentedControl is to use it like a tab view controller, where you want to switch between different view controllers. This post will demonstrate how to achieve this functionality in Swift through the UIViewController containment API, that allows embedding your UIViewController inside another. Also how to style your segmented control to look like a typical tab bar.While working on Zingoo, we had a requirement to switch between the photos and the info tabs through an Android-like tab bar. This was the target UI to achieve.

Continue reading