Search code examples
iosecslidingviewcontroller

Closing ECSlidingViewController menu


I'd like to implement my sliding menu in a way that pressing the Menu button will show my menu and pressing Menu again would hide it. But I can't understand how to do it with ECSlidingViewController. Will appreciate any help.


Solution

  • ECSlidingViewController has methods for this: anchorTopViewToRightAnimated:, anchorTopViewToLeftAnimated: and resetTopViewAnimated:.

    Example in your top view controller:

    [self.slidingViewController anchorTopViewToRightAnimated:YES]
    

    ECSlidingViewController provides a category for UIViewController adding this slidingViewController property.

    You may also want to use ECSlidingViewController's currentTopViewPosition to determine if your button should show your menu or hide it in the current context.