zoukankan      html  css  js  c++  java
  • (一〇七)iPad开发之modal的切换方式与展示方式

    在iPad上modal有四种切换方式,分别是竖直进入(由下到上,默认方式)、水平翻转、淡入淡出。

    属性要设置在将要modal出来的控制器上:

        /*
         typedef NS_ENUM(NSInteger, UIModalTransitionStyle) {
         UIModalTransitionStyleCoverVertical = 0,
         UIModalTransitionStyleFlipHorizontal,
         UIModalTransitionStyleCrossDissolve,
         UIModalTransitionStylePartialCurl NS_ENUM_AVAILABLE_IOS(3_2),
         };
         */
        
        // 注意iOS7翻页(UIModalTransitionStylePartialCurl)只能漏出下面控制器的一部分,注意翻页只能在控制器全屏显示时使用。
        vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    除了进入方式,还有展示方式,常用的展示方式是FormSheet,这个方式不会全屏展示,而是在屏幕中央的小区域展示。PageSheet显示一个宽度固定为768点,高度随屏幕变化的页面。

        /*
        typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
            UIModalPresentationFullScreen = 0,
            UIModalPresentationPageSheet NS_ENUM_AVAILABLE_IOS(3_2),
            UIModalPresentationFormSheet NS_ENUM_AVAILABLE_IOS(3_2),
            UIModalPresentationCurrentContext NS_ENUM_AVAILABLE_IOS(3_2),
            UIModalPresentationCustom NS_ENUM_AVAILABLE_IOS(7_0),
            UIModalPresentationOverFullScreen NS_ENUM_AVAILABLE_IOS(8_0),
            UIModalPresentationOverCurrentContext NS_ENUM_AVAILABLE_IOS(8_0),
            UIModalPresentationPopover NS_ENUM_AVAILABLE_IOS(8_0),
            UIModalPresentationNone NS_ENUM_AVAILABLE_IOS(7_0) = -1,
        };*/
        // PageSheet宽度固定为768,高度为当前屏幕高度
        // FormSheet在中央显示一小块,常用,注意和popover区分。
        vc.modalPresentationStyle = UIModalPresentationFormSheet;
    modal的方式还是原来的方法, 并且dismiss时按照设定的方式退出。

        [self presentViewController:vc animated:YES completion:nil];

    从控制器1触摸modal控制器2的完整代码如下:

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
        
        ViewController2 *vc = [[ViewController2 alloc] init];
        vc.view.backgroundColor = [UIColor redColor];
        
        /*
         typedef NS_ENUM(NSInteger, UIModalTransitionStyle) {
         UIModalTransitionStyleCoverVertical = 0,
         UIModalTransitionStyleFlipHorizontal,
         UIModalTransitionStyleCrossDissolve,
         UIModalTransitionStylePartialCurl NS_ENUM_AVAILABLE_IOS(3_2),
         };
         */
        
        // 注意iOS7翻页(UIModalTransitionStylePartialCurl)只能漏出下面控制器的一部分,注意翻页只能在控制器全屏显示时使用。
        vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        
        /*
        typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
            UIModalPresentationFullScreen = 0,
            UIModalPresentationPageSheet NS_ENUM_AVAILABLE_IOS(3_2),
            UIModalPresentationFormSheet NS_ENUM_AVAILABLE_IOS(3_2),
            UIModalPresentationCurrentContext NS_ENUM_AVAILABLE_IOS(3_2),
            UIModalPresentationCustom NS_ENUM_AVAILABLE_IOS(7_0),
            UIModalPresentationOverFullScreen NS_ENUM_AVAILABLE_IOS(8_0),
            UIModalPresentationOverCurrentContext NS_ENUM_AVAILABLE_IOS(8_0),
            UIModalPresentationPopover NS_ENUM_AVAILABLE_IOS(8_0),
            UIModalPresentationNone NS_ENUM_AVAILABLE_IOS(7_0) = -1,
        };*/
        // PageSheet宽度固定为768,高度为当前屏幕高度
        // FormSheet在中央显示一小块,常用,注意和popover区分。
        vc.modalPresentationStyle = UIModalPresentationFormSheet;
        
        [self presentViewController:vc animated:YES completion:nil];
        
    

  • 相关阅读:
    在DevExpress程序中使用SplashScreenManager控件实现启动闪屏和等待信息窗口
    使用Setup Factory安装包制作工具制作安装包
    PostgreSQL介绍以及如何开发框架中使用PostgreSQL数据库
    在DevExpress中使用CameraControl控件进行摄像头图像采集
    读取数据库信息构建视图字段的备注信息,方便程序代码生成
    混合框架中Oracle数据库的还原处理操作
    使用图片视频展示插件blueimp Gallery改造网站的视频图片展示
    .NET缓存框架CacheManager在混合式开发框架中的应用(1)-CacheManager的介绍和使用
    在Winform界面菜单中实现动态增加【最近使用的文件】菜单项
    文字处理控件TX Text Control的使用
  • 原文地址:https://www.cnblogs.com/aiwz/p/6154080.html
Copyright © 2011-2022 走看看