- April 27, 2024
- Mins Read
Inspired by this project on Dribbble
Also, read how it was done in our blog
pod ‘GuillotineMenu’
You are welcome to see the sample of the project for fully operating sample in the Example folder.
let menuViewController = storyboard!.instantiateViewController(withIdentifier: “MenuViewController”)
menuViewController.modalPresentationStyle = .custom
menuViewController.transitioningDelegate = self
extension ViewController: UIViewControllerTransitioningDelegate {
func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
presentationAnimator.mode = .presentation
return presentationAnimator
}
func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
presentationAnimator.mode = .dismissal
return presentationAnimator
}
presentationAnimator.supportView = navigationController!.navigationBar
presentationAnimator.presentButton = sender
present(menuViewController, animated: true, completion: nil)
Of course, you can assign different “supportView” or “presentButton” for menu, but we think that’s the best case would be behaviour like in Example project.
To specify the length of an animation effect, change the value of the “duration” property.
Also, you have wonderful delegate methods of animator:
public protocol GuillotineAnimationDelegate: class {
func animatorDidFinishPresentation(_ animator: GuillotineTransitionAnimation)
func animatorDidFinishDismissal(_ animator: GuillotineTransitionAnimation)
func animatorWillStartPresentation(_ animator: GuillotineTransitionAnimation)
func animatorWillStartDismissal(_ animator: GuillotineTransitionAnimation)
}
You can do whatever you want alongside menu is animating.
We’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation.
P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!
Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...