To run the example project, clone the repo, and run pod install
from the Example directory first.
import BXTransition
class ViewController: UIViewController {
var transition: BXTransition!
let interactor = Interactor()
override func viewDidLoad() {
}
override func viewDidAppear(_ animated: Bool) {
transition = BXTransition(viewController: self)
transition.interactor = interactor
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController1 = storyboard.instantiateViewController(withIdentifier: "ViewController1")
viewController1.transitioningDelegate = self
transition.set(viewController: viewController1, forDirection: .right)
}
@IBAction func pangGesture(_ sender: Any) {
guard let gesture = sender as? UIGestureRecognizer else { return }
transition.panGesture(view: view, gesture: gesture)
}
}
extension ViewController: UIViewControllerTransitioningDelegate {
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return transition
}
func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return interactor.hasStarted ? interactor : nil
}
}
import BXTransition
class ViewController1: UIViewController {
var transition: BXTransition!
let interactor = Interactor()
override func viewDidAppear(_ animated: Bool) {
transitioningDelegate = self
transition = BXTransition(viewController: self)
transition.interactor = interactor
transition.setDismiss(directionAccepted: .left)
}
@IBAction func pangGesture(_ sender: Any) {
guard let gesture = sender as? UIGestureRecognizer else { return }
transition.panGesture(view: view, gesture: gesture)
}
}
extension ViewController1: UIViewControllerTransitioningDelegate {
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return transition
}
func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return interactor.hasStarted ? interactor : nil
}
}
BXTransition is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'BXTransition'
Breno Xavier - [email protected]
BXTransition is available under the MIT license. See the LICENSE file for more info.