zoukankan      html  css  js  c++  java
  • iOS側拉栏抽屉效果Demo

    側拉栏抽屉效果Demo
     须要导入第三方的类库例如以下:


    抽屉效果所需第三方类库下载



    效果:既能够两側都实现抽屉效果也可仅仅实现左側栏或者右側栏的抽屉效果
     
                                      


    关于抽屉效果主要是AppDelegate的代码

    AppDelegate.h文件代码:

    <span style="font-size:18px;"><span style="font-size:18px;">#import <UIKit/UIKit.h>
    
    @interface YJFAppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    @end</span></span>
    

    AppDelegate.m文件代码

    <span style="font-size:18px;"><span style="font-size:24px;"><span style="font-size:18px;">#import "YJFAppDelegate.h"
    #import "CustomizedNavigationController.h"
    #import "FirstViewController.h"
    #import "SecondViewController.h"
    #import "ThirdViewController.h"
    @implementation YJFAppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        //主视图
        FirstViewController *firstVC = [[FirstViewController alloc] init];
        //左边视图
        SecondViewController *secondVC = [[SecondViewController alloc] init];
        //右边视图
        ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
        
        CustomizedNavigationController *navigationVC = [[CustomizedNavigationController alloc] initWithRootViewController:firstVC];
        
    
        CustomizedNavigationController *leftNavigationVC = [[CustomizedNavigationController alloc] initWithRootViewController:secondVC];
    
        CustomizedNavigationController *rightNavigationVC = [[CustomizedNavigationController alloc] initWithRootViewController:thirdVC];
    
        //抽屉管理 第三方
        //该第三方既能够仅仅实现打开左側栏也能够实现打开右側栏,还能够同一时候都实现
        MMDrawerController *rooVC = [[MMDrawerController alloc] initWithCenterViewController:navigationVC leftDrawerViewController:leftNavigationVC rightDrawerViewController:rightNavigationVC];
        
        //仅仅实现打开左側栏
        //MMDrawerController *rooVCLeft = [[MMDrawerController alloc] initWithCenterViewController:navigationVC leftDrawerViewController:firstVC];
        //仅仅实现打开右側栏
        //MMDrawerController *rooVCRight = [[MMDrawerController alloc] initWithCenterViewController:navigationVC rightDrawerViewController:thirdVC];
        
        //指定window的根视图
        self.window.rootViewController = rooVC;
        //測了门的宽度
        [rooVC setMaximumLeftDrawerWidth:270];
        //设置側拉门开与关的动画
        [rooVC setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
        [rooVC setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
        //側开内容展示效果
        //设置向左滑动打开右側栏
        [[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:MMDrawerAnimationTypeNone];
        //设置向右滑动打开左側栏
        [[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:MMDrawerAnimationTypeNone];
        
        //
        [rooVC setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
            MMDrawerControllerDrawerVisualStateBlock block;
            block = [[MMExampleDrawerVisualStateManager sharedManager]
                     drawerVisualStateBlockForDrawerSide:drawerSide];
            if(block){
                block(drawerController, drawerSide, percentVisible);
            }
    
        }];
        
        
    
    
    
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        return YES;
    }</span>
    </span>
    </span>


  • 相关阅读:
    vnc mirror driver cannot be installed rdp connection解决方法
    安装.Net Framework 4.6.2时出现“无法建立到信任根颁发机构的证书链”解决方法 一、错误
    MCP2515 CAN总线模块介绍
    HarmonyOS HiSpark Wi-Fi IoT套件】使用HiBurn烧录鸿蒙.bin文件到Hi3861芯片
    鸿蒙开发板hi3861 VScode DevEco无法使用 compilerPath“riscv32-unknown-elf-gcc
    c# http协议 web api发送,获取方法-获取网页数据
    JS图片按比例加载
    哪些法宝值得接
    法宝合成时的五行位置分配是什么
    跨数据库导数据,可自选行内容
  • 原文地址:https://www.cnblogs.com/wzzkaifa/p/6863702.html
Copyright © 2011-2022 走看看