Build Custom UIViewController Transition with Custom Animation

How to Build Custom UIViewController Transition With Custom Animation

0
Shares
How to Build Custom UIViewController Transition With Custom Animation
Rate this post

If you look at any mobile app, you’ll notice some kind of custom animations as you move from one screen to another. This can be achieved with UIViewController. The way these UIViewController is presented in master-detail views with a swipe gesture that slides the detail view with custom animation proved to be very appealing to app users.

The iOS 7 introduced this UIViewController which makes it possible for developers to create transitions with custom animation. And in this iOS app tutorial, we’ll take a look at how to exactly achieve this.

Let’s Get Started

Create a new project under file menu with ‘Single View Application’.

animation1

animation2

Create a new class “TransitionVC” and ViewController in Main.Storyboard

Add a button “Custom” in ViewController in Main.Storyboard and create a custom segue.

animation3

Write the following code in ViewController.swift

class CustomSegue: UIStoryboardSegue {

override func perform() {

let source = sourceViewController as UIViewController

let destination = destinationViewController as UIViewController

let window = UIApplication.sharedApplication().keyWindow!

 

destination.view.alpha = 0.0

window.insertSubview(destination.view, belowSubview: source.view)

 

UIView.animateWithDuration(0.5, animations: { () -> Void in

source.view.alpha = 0.0

destination.view.alpha = 1.0

}) { (finished) -> Void in

source.view.alpha = 1.0

source.presentViewController(destination, animated: false, completion: nil)

}

}

}

Now add this class in segue.

animation4

And done!

If you run the demo, it will look like this.

However, if you face any problem implementing it, you can contact our developers for help.

So now you know how to create custom UIViewController transition and how to make this custom animation transition interactive. You should also know that with these features, you can have full control over your iPhone mobile app transition animations to build unique and intriguing user experiences to delight your app users. Knowing all these, upgrading your app UI makes sense. And if you need technical assistance, you can hire iPhone app developer from us to help you update your mobile app.

Grab a free copy of UIViewController transition demo from Github.

 
0
Shares
 

Want to Develop Interactive iPhone App? Contact Us Now

Get your free consultation now