Custom Right Side Slide Out Menu in iOS
In this tutorial , i will tell you about how to implement Custom right side menu in Objective c . Slide out menu is similar to what you see in popular apps like Facebook , Gmail .
Step 1 : Create a new project and save it to the desired location.
![]() |
New project |
Step 2: Add MFSideMenu to the project.
1. Close the project which you have created.
2. Go to MFSideMenu to add it to your project.
3. For installing pods , Open terminal in your mac.
i) Open your project by writing `cd name of the project` .
ii) Write pod init.
iii) Write open -a Xcode PodFile.
iv) Add pod to your pod file pod 'MFSideMenu'
v) Close the pod file and write pod install to install pod in terminal.
Step 3: Open Workspace
i) After pod installation , close the terminal window. A new workspace is created for your project.
ii) Open the workspace.
Step 4: Open Main.storyboard and embed a new navigation controller in it .
i) Add the title to your viewController and drag a UIBarButton to the right side of the navigation controller (name it as MENU)
ii) Make its connection (as action) with the Viewcontroller .
Step 5 : Create a helper class which will contain the elements of the slide out menu .
i) On Xcode, hit cmd + n and add a new tableViewController to your project .
ii) Add the following code in your tableviewController
Step 6 : Open AppDelagate.h and add the following code :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import "MFSideMenu.h" | |
#import "SideMenuViewController.h" | |
#import "ViewController.h" | |
@interface AppDelegate : UIResponder <UIApplicationDelegate> | |
@property (strong, nonatomic) UIWindow *window; | |
@end | |
i) Open Main.StoryBoard and app the identifier to it . (e.g. : myStory).
![]() |
Add caption |
ii) In appDelegate.m add the following code :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface AppDelegate () | |
@end | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch. | |
// UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; | |
ViewController *viewCtrl= [[UIStoryboard storyboardWithName:@"Main" bundle:NULL]instantiateViewControllerWithIdentifier:@"mainStory"]; | |
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewCtrl]; | |
SideMenuViewController *rightMenuViewController = [[SideMenuViewController alloc] init]; | |
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController | |
containerWithCenterViewController:nav | |
leftMenuViewController:nil | |
rightMenuViewController:rightMenuViewController]; | |
self.window.rootViewController=container; | |
return YES; | |
} |
iii) Now , open ViewController.m and the following code :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import "MFSideMenu.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
self.view.backgroundColor = [UIColor whiteColor]; | |
self.view.frame = [[UIScreen mainScreen] bounds]; | |
} | |
- (void)didReceiveMemoryWarning { | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (IBAction)menuBarBtn:(id)sender { | |
NSLog(@"Menu"); | |
[self.menuContainerViewController toggleRightSideMenuCompletion:^{}]; | |
} | |
@end |
For MFSideMenu Action :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
UINavigationController *navigationController = self.menuContainerViewController.centerViewController; | |
KnectsViewController *knectsVc = [[KnectsViewController alloc]init]; | |
NSArray *controllers = [NSArray arrayWithObject:knectsVc]; | |
navigationController.viewControllers = controllers; | |
[self.menuContainerViewController setMenuState:MFSideMenuStateClosed]; | |
} |
Thats all about Slide Out Menu in iOS .
Thank you .:)
Read about APNS (Apple Push Notification Service)
Read about POST data using NSURLSession
Thanks for this beautiful post IOS. It is really good for the beginners and I also liked the post.
ReplyDeleteIOS Training in Bangalore
IOS Training in Marathahalli