I need an sliding menu mentioned in the pic which is compatible for iOS 6 and iOS 7
Asked
Active
Viewed 337 times
2 Answers
0
You can check this tutorial. It will show you how to do this on both side of the phone.
If you don't want to read all of this :
The main idea is to have a view below the main view. When you slide or touch your menu button, you just move your top view by doing the following (i did this on a class inherited by all of my view controllers, but you're free to do it anywhere you want / need it) :
// self.isMenuOpened is a flag to save menu state and set the move distance (and a few other things)
// Init move distance
float move = 270; // 270 is arbitrary value, you can set it as you like
if (self.isMenuOpened) { move = -move; }
// Moves all view except menu
[UIView beginAnimations:@"openMenu" context:nil];
[UIView setAnimationDuration:kAnimationDurationShort];
// Navigation bar frame moving (if you have one)
CGRect navFrame = self.navigationController.navigationBar.frame;
self.navigationController.navigationBar.frame = CGRectMake(navFrame.origin.x + move,
navFrame.origin.y,
navFrame.size.width,
navFrame.size.height);
// Call switching move on each view
BOOL first = true;
for (UIView *view in [self.view subviews]) {
if (first) { first = false; } // First view is menu if it's on minimum zIndex
else {
CGRect mainViewFrame = view.frame;
[view setUserInteractionEnabled:self.isMenuOpened]; // Disable your main view as it still visible
view.frame = CGRectMake(mainViewFrame.origin.x + move, mainViewFrame.origin.y,
mainViewFrame.size.width, mainViewFrame.size.height);
}
}
[UIView commitAnimations];
I iterate through all of my subviews because, in a few cases, i added a view or two. But if you have a single view (and then your menu below), you don't have to do all the iteration stuff. Hope that helps !

Jissay
- 550
- 9
- 28
0
You can use this awesome and simple library
https://github.com/arturdev/AMSlideMenu
which supports left and right menus and fully customizable

arturdev
- 10,884
- 2
- 39
- 67