Skip to content

charleslima/iOS-Custom-Transitions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

iOSCustomTransitions

Screenshot

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

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

pod 'iOSCustomTransitions'

Usage

Import iOSCustomTransitions

import iOSCustomTransitions

To use custom transitions your ViewController needs to conforms to UIViewControllerTransitioningDelegate as the following example.

extension MyViewController: UIViewControllerTransitioningDelegate {

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return ZoomingPresentAnimator(originFrame: self.cardButton.frame, transitionStyle: .mixed, originViewSnapshot: self.cardButton.snapshotView(afterScreenUpdates: true))
    }

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return ZoomingDismissAnimator(destinationFrame: self.cardButton.frame, transitionStyle: .mixed, destinationViewSnapshot: self.cardButton.snapshotView(afterScreenUpdates: false))
    }
}

Also you need to set the transitioningDelegate of destination ViewController to your origin ViewController

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.transitioningDelegate = self
}

The following Transitions is available until now:

  • ZoomingPresentAnimator
  • ZoomingDismissAnimator
  • BubblePresentAnimatorController
  • BubbleDismissAnimatorController

Author

charleslima, [email protected]

License

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published