iOS新手入门:MMDrawerController 控件学习

2014-10-22 16:49:58     91 人阅读    

MMDrawerController是一个iOS抽屉式导航控件,支持自定义的过渡动画(滑动,滑动和缩放等)来展示或者隐藏“抽屉”。

github地址如下:https://github.com/mutualmobile/MMDrawerController

新建一个MMDrawerController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
{
 
    // Override point for customization after application launch.
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
 

    LeftViewController * leftDrawer = [[LeftViewController alloc] init];
 
    leftDrawer.view.backgroundColor = [UIColor blackColor];
 
    UIViewController * center = [[UIViewController alloc] init];
 
    center.view.backgroundColor = [UIColor yellowColor];
 
    UIViewController * rightDrawer = [[UIViewController alloc] init];
 
    rightDrawer.view.backgroundColor = [UIColor greenColor];
 

    MMDrawerController * drawerController = [[MMDrawerController alloc]
 
                                             initWithCenterViewController:center
 
                                             leftDrawerViewController:leftDrawer
 
                                             rightDrawerViewController:rightDrawer];
 

    [drawerController setMaximumRightDrawerWidth:200];
 
    [drawerController setMaximumLeftDrawerWidth:200];



    [drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
 
    [drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
 

    window.rootViewController = drawerController;
 
    [window makeKeyAndVisible];
 
    return YES;
}
}

然后让向右滑动的时候,左边的视图就会显示出来,当前的视图就会向右移动。当点击左边视图中的按钮时,就会重新加载中间的视图。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
{
 
    if (indexPath.row == 0) {
 
        NewCenterViewController *center = [[NewCenterViewController alloc] init];
 
        [self.mm_drawerController
 
         setCenterViewController:center
 
         withCloseAnimation:YES
 
         completion:nil];
 
    }else{
 
        UIViewController *center = [[UIViewController alloc] init];
 
        [center.view setBackgroundColor:[UIColor blueColor]];
 
        [self.mm_drawerController
 
         setCenterViewController:center
 
         withCloseAnimation:YES
 
         completion:nil];
 
    }



}
}

 

自带的例子比较复杂,我写了个简单的:https://www.dropbox.com/s/akue00udgprqwud/Demo.zip


原文地址:http://www.itmmd.com/201410/52.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。

iOS新手入门:开源项目AFNetworking 网络库学习   上一篇
下一篇  Apache性能调优1

精彩回复
发表评论
姓名:       

《程序员app》专门为程序员量身定做!