Instantly share code, notes, and snippets.
tylerlantern
/ BHMenuTransitionManagerPart1.swift
Created
December 24, 2018 15:22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BHMenuTransitionManager: NSObject { | |
var transitionAnimator : BHMenuTransitionAnimator! | |
init(instance : BHMenuTransitionManagerDelegate,fromViewController vc: UIViewController ) { | |
super.init() | |
transitionAnimator = BHMenuTransitionAnimator(fromViewController: vc) | |
} | |
} |
tylerlantern
/ BHMenuTransitionAnimatorPart2.swift
Created
December 24, 2018 15:21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | |
let containerView = transitionContext.containerView | |
transitionContext.viewController(forKey: .from) | |
let fromVc = transitionContext.viewController(forKey: .from)! | |
let toVc = transitionContext.viewController(forKey: .to)! | |
let isPresenting = self.fromViewController == fromVc ? true : false | |
if isPresenting{ | |
let targetWidth = fromVc.view.frame.width * 0.85 | |
toVc.view.frame = CGRect(x: targetWidth * -1, y: 0, width: targetWidth, height: fromVc.view.frame.height) | |
containerView.addSubview(toVc.view) |
tylerlantern
/ BHMenuTransitionAnimatorPart1.swift
Last active
December 24, 2018 15:20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BHMenuTransitionAnimator: NSObject , UIViewControllerAnimatedTransitioning { | |
var fromViewController : UIViewController! | |
init(fromViewController vc : UIViewController ) { | |
super.init() | |
self.fromViewController = vc | |
} | |
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { |
NewerOlder