Created
December 7, 2018 09:27
-
-
Save Denismih/315322f61c63f9787e398c4e6955d7d3 to your computer and use it in GitHub Desktop.
push from bottom
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
// push view controller but animate modally | |
let storyBoard: UIStoryboard = UIStoryboard(name: "myStoryBoard", bundle: nil) | |
let vc = storyBoard.instantiateViewController(withIdentifier: "myViewControllerIdentifier") as! MyViewController | |
let navigationController = self.navigationController | |
vc.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Close", style: .plain, target: vc, action: #selector(vc.closeView)) | |
vc.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: vc, action: nil) | |
let transition = CATransition() | |
transition.duration = 0.5 | |
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) | |
transition.type = kCATransitionMoveIn | |
transition.subtype = kCATransitionFromTop | |
navigationController?.view.layer.add(transition, forKey: nil) | |
navigationController?.pushViewController(vc, animated: false) | |
and in vc for pop: | |
func closeView() { | |
let transition = CATransition() | |
transition.duration = 0.5 | |
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) | |
transition.type = kCATransitionReveal | |
transition.subtype = kCATransitionFromBottom | |
navigationController?.view.layer.add(transition, forKey: nil) | |
_ = navigationController?.popViewController(animated: false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment