Skip to content

Instantly share code, notes, and snippets.

@dropocol
Forked from Daemon-Devarshi/Pop.swift
Created April 22, 2017 05:58
Show Gist options
  • Select an option

  • Save dropocol/f095f7665d76433b13d32df9d3e66808 to your computer and use it in GitHub Desktop.

Select an option

Save dropocol/f095f7665d76433b13d32df9d3e66808 to your computer and use it in GitHub Desktop.

Revisions

  1. @Daemon-Devarshi Daemon-Devarshi created this gist Oct 27, 2016.
    17 changes: 17 additions & 0 deletions Pop.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    protocol Pop {
    func moveBackToParentViewController(currentViewController: UIViewController)
    }

    extension Pop {
    func moveBackToParentViewController(currentViewController: UIViewController) {

    let transition = CATransition()
    transition.duration = 0.5
    transition.type = kCATransitionMoveIn
    transition.subtype = kCATransitionFromLeft

    currentViewController.view.window!.layer.add(transition, forKey: kCATransition)

    currentViewController.dismiss(animated: true, completion: nil)
    }
    }
    13 changes: 13 additions & 0 deletions Push.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    import UIKit

    class Push: UIStoryboardSegue {
    override func perform() {
    let transition = CATransition()
    transition.duration = 0.5
    transition.type = kCATransitionPush
    transition.subtype = kCATransitionFromRight

    source.view.window!.layer.add(transition, forKey: kCATransition)
    source.present(destination, animated: false, completion: nil)
    }
    }
    5 changes: 5 additions & 0 deletions PushedViewController.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    class PushedViewController: UIViewController, Pop {
    @IBAction func backAction(_ sender: AnyObject) {
    moveBackToParentViewController(currentViewController: self)
    }
    }