TransitionTreasury is a viewController transition framework in Swift.
- Push & Present
- Easy create transition & extension
- Support completion callback
- Support modal viewController data callback
- Support Custom Transition
- Complete Documentation
- iOS 8.0+
- Xcode 7.1+
- If you need help or found a bug, open an issue.
- If you have a new transition animation or want to contribute, submit a pull request. :]
Your viewController must conform TRTransition
. Code like this:
class OMINViewController: UIViewController, TRTransition {
var tr_transition: TRNavgationTransitionDelegate?
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let view = touches.first?.view {
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("OMINViewController")
navigationController?.tr_pushViewController(vc, method: .OMIN(keyView: view), completion: {
print("Push finish")
})
}
}
}
Your MainViewController must conform ModalViewControllerDelegate
, and your ModalViewController must conform MainViewControllerDelegate
. Code like this:
/// MainViewController.swift
var tr_transition: TRViewControllerTransitionDelegate?
@IBAction func tr_presentVC(sender: UIButton) {
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ModalViewController") as! ModalViewController
vc.modalDelegate = self
let nav = UINavigationController(rootViewController: vc)
tr_presentViewController(nav, method: .Twitter, completion: nil)
}
/// ModalViewController.swift
weak var modalDelegate: ModalViewControllerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: true)
}
@IBAction func pop(sender: AnyObject) {
modalDelegate?.modalViewControllerDismiss(callbackData: ["data":"back"])
}
Note:
If you don't need callbackData, maybe you haven't implementedfunc modalViewControllerDismiss(callbackData data:Dictionary<String,AnyObject>?)
.
You shouldn't usetr_dismissViewController()
in your ModalViewController. Please usedelegate
. I have implented this, just usemodalDelegate?.modalViewControllerDismiss(callbackData: ["data":"back"])
. For more, you can read Dismissing a Presented View Controller.
TransitionTreasury is released under the MIT license. See LICENSE for details.