티스토리 뷰

Develope/Objective-c

ios ( Objective-c) slide menu

Jason park@ 2016. 6. 12. 00:03
반응형

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;

}


반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함