All Projects → Touchwonders → Transition

Touchwonders / Transition

Licence: mit
Easy interactive interruptible custom ViewController transitions

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Transition

Aicustomviewcontrollertransition
Easy and tidy way for creating custom UIViewController transitions for iOS
Stars: ✭ 130 (-94.93%)
Mutual labels:  transition, custom, interactive, viewcontroller
MVVM-Design-Pattern-Demo
An Xcode 9 project written in Swift 4 code designed using the MVVM design pattern, truly extolling the virtues of MVVM over MVC.
Stars: ✭ 31 (-98.79%)
Mutual labels:  view, controller, viewcontroller
SPLarkController
Custom transition between controllers. Settings controller for your iOS app.
Stars: ✭ 967 (-62.31%)
Mutual labels:  custom, controller, transition
Splarkcontroller
Custom transition between controllers. Settings controller for your iOS app.
Stars: ✭ 693 (-72.99%)
Mutual labels:  controller, transition, custom
Imageslideshow
A Swift Image SlideShow for iOS
Stars: ✭ 68 (-97.35%)
Mutual labels:  controller, viewcontroller
Dotsloaderview
Simple dots loader view
Stars: ✭ 63 (-97.54%)
Mutual labels:  view, custom
Mkloader
Beautiful and smooth custom loading views
Stars: ✭ 1,377 (-46.34%)
Mutual labels:  view, custom
Stfalconimageviewer
A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures
Stars: ✭ 1,734 (-32.42%)
Mutual labels:  transition, transitions
Swipeablecards
Demonstration of draggable transition for UIViewController with swipeable UICollectionView cells inside.
Stars: ✭ 52 (-97.97%)
Mutual labels:  transition, interactive
Rdgliderviewcontroller Swift
Control for a floating view gliding over a ViewController Edit
Stars: ✭ 102 (-96.02%)
Mutual labels:  view, viewcontroller
Arclayout
With Arc Layout explore new styles and approaches on material design
Stars: ✭ 1,662 (-35.23%)
Mutual labels:  view, custom
Revealbanner
🚀🚀🚀 滑动特效banner
Stars: ✭ 209 (-91.86%)
Mutual labels:  view, custom
Zwtopselectvcview
快速导入多个控制器,通过顶部选择菜单切换控制器,实现一个页面多个控制器切换处理.(It's an so easy way to add your all kinds of childControllers into superViewController, then you can slide around or just click on the topButton which is automatically building in the topView to switch your childViewController.)
Stars: ✭ 61 (-97.62%)
Mutual labels:  controller, view
Sunset.css
This library offers a collection of different CSS-powered transitions.
Stars: ✭ 99 (-96.14%)
Mutual labels:  transition, transitions
Fiftyshadesof
An elegant context-care loading placeholder for Android
Stars: ✭ 1,110 (-56.74%)
Mutual labels:  view, custom
Diamond
Diamond is a full-stack web-framework written in The D Programming Language using vibe.d
Stars: ✭ 173 (-93.26%)
Mutual labels:  controller, view
Slidingsquareloaderview
Marvelous sliding square loader view
Stars: ✭ 166 (-93.53%)
Mutual labels:  view, custom
Spstorkcontroller
Now playing controller from Apple Music, Mail & Podcasts Apple's apps.
Stars: ✭ 2,494 (-2.81%)
Mutual labels:  controller, transition
Atgmediabrowser
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.
Stars: ✭ 186 (-92.75%)
Mutual labels:  transition, custom
Hhcustomcorner
Awesome library to customize corners of UIView and UIButton. Now you can customize each corner differently
Stars: ✭ 36 (-98.6%)
Mutual labels:  view, custom
Transition

CocoaPods version Carthage compatible license platform

Introduction

Transition is a library that helps you build iOS view controller transitions. Implementing a nice interactive custom view controller transition involves quite a number of components. You have to implement the correct delegates, handle the switching between passive animation and active interaction phases, ensure the timing is right, think of interruption and cancellation, keep responsibilities separated... It quickly gets messy! This is where Transition helps you out: you just define the animation and the interaction, Transition ties it all together.

In short:

  • You specify single-responsibility components (animation, interaction, ...)
  • Transition ties them together

Examples

There are several examples (which can be found in Examples/):

  1. SimpleExample: implements the basic steps explained in this README.
  2. TabBarTransitionsExample: shows you how to implement custom UITabBarController transition animations with custom interaction.
  3. ModalTransitionsExample: shows you how to implement custom modal transition animations that include interaction with a shared element.
  4. BuiltInTransitionsCatalog: shows a small collection of built-in transition animations.

To run an example project, clone the repo, navigate to one of these example directories, and run pod install from that directory first.



Requirements

  • iOS 10.0+
  • Swift 3.0+

Usage

1. The AnimationLayer

The AnimationLayer is the most essential part of setting up a transition; without it, there'll be no animation. An AnimationLayer is a simple struct that takes two arguments:

1. Animation function

This is a simple closure with the signature () -> Void. In this closure you define your animation, just as you would with a UIView or UIViewPropertyAnimator animation. For each AnimationLayer, Transition will instantiate a UIViewPropertyAnimator, passing it your animation block.

2. TimingParameters

This defines the timing of your animation. It must be a UITimingCurveProvider, such as an instance of UICubicTimingParameters or UISpringTimingParameters.

(3. AnimationRange)

Additionally, you can set an AnimationRange, which by default is set to AnimationRange.full. This range defines the start and end point (as fractions of the total transition animation duration) between which your AnimationLayer's animation will run.

You create your AnimationLayer as follows:

let animationLayer = AnimationLayer(timingParameters: UICubicTimingParameters(animationCurve: .easeOut)
                                           animation: { topView?.transform = targetTransform })

😦 ... Hey, wait! Where do that topView and targetTransform come from?

2. The TransitionAnimation

Your AnimationLayer is defined as a part of your TransitionAnimation. This represents all (non-interactive) animation during a transition. The TransitionAnimation protocol exposes an array of AnimationLayers. Additionally it contains two functions; one for setup and one for completion. Before starting animation, your setup function will be called, passing you the transitioningContext that among others contains the fromView and toView in the transition. The completion function is called when the entire transition completes, allowing you to clean up any temporary views added in the setup.

class SimpleAnimation : TransitionAnimation {
    
    private weak var topView: UIView?
    private var targetTransform: CGAffineTransform = .identity
    
    func setup(in operationContext: TransitionOperationContext) {
        let context = operationContext.context
        let isPresenting = operationContext.operation.isPresenting
        
        //  We have to add the toView to the transitionContext, at the appropriate index:
        if isPresenting {
            context.containerView.addSubview(context.toView)
        } else {
            context.containerView.insertSubview(context.toView, at: 0)
        }
        context.toView.frame = context.finalFrame(for: context.toViewController)
        
        //  We only animate the view that will be on top:
        topView = isPresenting ? context.toView : context.fromView
        
        let hiddenTransform = CGAffineTransform(translationX: 0, y: -context.containerView.bounds.height)
        
        topView?.transform = isPresenting ? hiddenTransform : .identity
        targetTransform = isPresenting ? .identity : hiddenTransform
    }
    
    var layers: [AnimationLayer] {
        return [AnimationLayer(timingParameters: AnimationTimingParameters(animationCurve: .easeOut), animation: animate)]
    }
    
    func animate() {
        topView?.transform = targetTransform
    }
    
    func completion(position: UIViewAnimatingPosition) {}
}

🤔 ... But what about duration?

3. The Transition

You just defined the animation of your transition. You now create a Transition struct that has an animation part (your TransitionAnimation) and an optional sharedElement part, which you can see implemented in the Modal and Navigation examples. And the Transition has a duration!

let transition = Transition(duration: 2.0, animation: SimpleAnimation())

😬 ... And where do I put that transition?

4. The TransitionController

Almost there. Say you want to use this transition for UINavigationController transitions. Let's make a convenience object that isolates transition-related functionality for a navigationController:

class MyNavigationTransitions {
    let transitionController: TransitionController
    let transitionsSource = MyNavigationTransitionSource()
    
    init(navigationController: UINavigationController) {
        transitionController = TransitionController(forTransitionsIn: navigationController, transitionsSource: transitionsSource)
    }
}

class MyNavigationTransitionSource : TransitionsSource {
    func transitionFor(operationContext: TransitionOperationContext, interactionController: TransitionInteractionController?) -> Transition {
        return Transition(duration: 0.5, animation: SimpleAnimation())
    }
}

The TransitionController takes responsibility for animating transitions in the given navigationController, using an external TransitionsSource to provide operation-specific transitions (the operation – in this case push or pop – can be obtained from the TransitionOperationContext). This means you can return different transition animations for push and pop. You can also provide a single animation that behaves differently depending on the operation (see the SimpleAnimation).

Now, initialize your MyNavigationTransitions, passing it your navigationController.

🤓 ... Is that it?

Yes!

😎

At least, for custom view controller transition animations. There's a lot more that'll help you set up a custom interaction gesture and a shared element that can move between the transitioning views.

The above steps are implemented in the SimpleExample that can be found in the Examples/ directory.

Further reading

Installation

Transition is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Transition'

Your input is welcome!

If you have any suggestions, please get in touch with us. Feel free to fork and submit pull requests. Also, we're Dutch, so if any naming is odd, might be improved or is just plain inappropriate, let us know!

Backlog

License

Transition is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].