ios ( Objective-c) slide menu
ios slide menu 추천!
https://github.com/aryaxt/iOS-Slide-Menu
이것저것 찾아봤지만 해본것중 가장 사용이 쉽고 편리했다.
개인적으로 스토리보드 보다는 하드코딩을 선호하는 편으로, sample 앱이 스토리보드 기반이다 보니 하드코딩으로 하려면 다음과 같이 하면 된다.
AppDelegate.m 파일
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MainView *vc = [[MainView alloc] init]; // Navigation Controller 의 RootViewController 가 될 View
LeftMenuViewController *leftMenu = [[LeftMenuViewController alloc] init]; // 왼쪽 메뉴 뷰 파일
SlideNavigationController *nv = [[SlideNavigationController alloc] initWithRootViewController:vc];
[nv setLeftMenu:leftMenu];
[nv setMenuRevealAnimationDuration:.18];
[nv.navigationBar setHidden:YES];
[nv.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
//[SlideNavigationController sharedInstance].leftMenu = leftMenu;
//[SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18;
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidClose object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Closed %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidOpen object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Opened %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Revealed %@", menu);
}];
[self.window setRootViewController:nv];
[self.window makeKeyAndVisible];
return YES;
}