Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated usage description #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,34 @@ pod 'YALSideMenu', '~> 2.1'
self.dismiss(animated: true, completion: nil)
}
```
If you want, for example, to dismiss your menu when a tap outside menu takes place, you should pass 'false' to 'shouldPassEventsOutsideMenu' flag and assign a 'tappedOutsideHandler'.In fact, you are free to do whatever you want when a tap outside menu occurs or, if you want to have access to your content view controller, just pass 'true' and assign 'tappedOutsideHandler' to nil.
6. Implement class of UIViewControllerTransitioningDelegate that will return our menuAnimator from method animationControllerForPresentedController and assign it to transitioningDelegate of menu view controller(Don't forget to set .Custom modal presentation style). To dismiss menu you should return MenuTransitionAnimator(mode: .Dismissal) from animationControllerForDismissedController method.
6. Dismisson on a tap outside menu (Optional):
If you want to dismiss your menu when a tap outside menu takes place, you should pass `false` to `shouldPassEventsOutsideMenu` flag and assign a `tappedOutsideHandler`.In fact, you are free to do whatever you want when a tap outside menu occurs or, if you want to have access to your content view controller, just pass 'true' and assign `tappedOutsideHandler` to nil.
7. Implement class of `UIViewControllerTransitioningDelegate` that will return our `menuAnimator` from method `animationControllerForPresentedController`. To dismiss menu you should return `MenuTransitionAnimator(mode: .Dismissal)` from `animationControllerForDismissedController` method.

```swift
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let menu = segue.destination as! MenuViewController
menu.transitioningDelegate = self
menu.modalPresentationStyle = .custom
}

func animationController(forPresented presented: UIViewController, presenting _: UIViewController,
source _: UIViewController) -> UIViewControllerAnimatedTransitioning? {
func animationController(
forPresented presented: UIViewController,
presenting _: UIViewController,
source _: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return menuAnimator
}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return MenuTransitionAnimator(mode: .dismissal)
}
```

8. Assign `transitioningDelegate` of menu view controller to self and set `modalPresentationStyle`to `.custom`.
```swift
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let menu = segue.destination as! MenuViewController
menu.transitioningDelegate = self
menu.modalPresentationStyle = .custom
}
```
9. Present your menu controller with a segue:
```swift
performSegue(withIdentifier: "menu", sender: self)
```
## Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation.
Expand Down