iOS, Objective-C, Swift, Design and Whatever Comes in Mind
‹ Back to the Blog

TTITransition: Share Element Transition

One of my open source projects is called 'TTITransition'.
It can be used to perform decent animations between two UIViewController.
Before you read on, please visit GitHub, simply because a visual topic as this can not only be describes in words.

The transition was derived from code that I have written for my first app TourTime but soon became a large bag of custom transitions.
My goal is, to provide as many visually appealing transitions as possible without going all too crazy about fancy animations.
Every transition should be informative to the user when it comes to navigation. Each and every effect should answer questions like 'Where do I go to, when I tap this Button?' and 'How do I get back to where I came from?'.

Screencast of one of my new take-along transition

Just recently, I added a way to animate several UIViews from one UIViewController to another one.
One can call it 'shared element transition', but I'll go with 'TakeAlong Transition'.

The adaption is rather simple:
Once you have initialized the TTITransitionController (you specify which kind of transition you would like to have, like: modal, inside of an UINavigationController or modal with a shared element).
Because there are views to animate form a initial to a final state, there are some information missing like 'What views should be passed form one ViewController to another?', 'Where are those views?' and 'Where should those views be, when the transition is finished?'
In order to provide answers to those questions, both of your presented and presenting ViewControllers have to implement a protocol.

On the presenting hand, TTITakeAlongTransitionProtocolForPresenting is implemented by the presenting ViewController (oh the surprise).

Using its only method dataForTakeAlongTransition, the system gathers information about the views that will participate in the transition. The method return an array of TTITakeAlongData objects, that hold every important information.

On the other hand, the presented ViewController is asked to implement the TTITakeAlongTransitionProtocolForPresentedprotocol.
Its only method is called takeAlongDataWithPopulatedFinalFramesForTakeAlongData:.
Here, every TTITakeAlongData object, that was prior passed to us by the presenting ViewController, is passed as an argument.
In this method, the TTITakeAlongData object is populated with the final state of the animated view. That means, that the presented ViewController will set the finalView property on the object.

Now, the system knows about the participating views, its initial and final state and the transition can take place.



Final notes:
I would love to implement this new kind of transition in swift (especially because I could have managed all the additional information using structs), but for several reasons, I needed to use Objective-C.
Its kind of a wired feeling, mainly because I have programmed mostly in Swift recently.
After all, I like the challenge of writing Objective-C code again but nevertheless, I enjoy Swift and the reduces obstacles.

"TTITransition: Share Element Transition".