Thejaswi Venigalla
Thejaswi Venigalla

Reputation: 141

Navigation drawer- sliding issue in ios

I am trying to create a sliding menu (like the one in google maps app) in which menu screen should be shown or added as subview over the existing screen on tapping a button. While showing it, the sub view should be animated from left to right. I tried to animate while adding it as subview, but failed in doing so. Can any one suggest how to do it? (or) Can I do it using navigation controller? Thanks in advance!!

Upvotes: 1

Views: 170

Answers (1)

Avi Tsadok
Avi Tsadok

Reputation: 1843

You need to add the subview, and set it's frame out of the screen.(320,0,100,568 for example). Of course it's better to use auto layout for that.

Add as subview:

[self.view addSubView:sideMenu];

When you want to show it, just change it's frame using animation block.

 [UIView animateWithDuration:0.2 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
    sideMenu.frame = CGRectMake(220,0,100,568);

} completion:^(BOOL finished) {
}];

As I said, it's better to use auto layout and not setting frames. I did it only for the example.

Upvotes: 1

Related Questions