模态页面的小知识点

最近遇到了2个简单的模态场景,供自己记录,方便使用

1、A页面模态一个新控制器,新控制器透明可以看到A页面的视图

ManagerChildAgeViewController *vc = [ManagerChildAgeViewController new];
vc.childDataArray = self.childDataArray;  
//设置ViewController的模态模式,即ViewController的显示方式
vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:vc animated:NO completion:^{
        
        [MBManager hidePPYXLogoAlert];
        //设置ViewController的背景颜色及透明度
        vc.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    }];

UIModalPresentationStyle的样式解析

      UIModalPresentationFullScreen =0,//由下到上,全屏覆盖
      UIModalPresentationPageSheet,//在portrait时是FullScreen,在landscape时和FormSheet模式一样。
      UIModalPresentationFormSheet,// 会将窗口缩小,使之居于屏幕中间。在portrait和landscape下都一样,但要注意landscape下如果软键盘出现,窗口位置会调整。
      UIModalPresentationCurrentContext,//这种模式下,presented VC的弹出方式和presenting VC的父VC的方式相同。
      UIModalPresentationCustom,//自定义视图展示风格,由一个自定义演示控制器和一个或多个自定义动画对象组成。符合UIViewControllerTransitioningDelegate协议。使用视图控制器的transitioningDelegate设定您的自定义转换。
      UIModalPresentationOverFullScreen,//如果视图没有被填满,底层视图可以透过
      UIModalPresentationOverCurrentContext,//视图全部被透过
      UIModalPresentationPopover,
      UIModalPresentationNone ,
};

UIModalTransitionStyle的动画效果展示

        UIModalTransitionStyleCoverVertical = 0,
        UIModalTransitionStyleFlipHorizontal __TVOS_PROHIBITED,
        UIModalTransitionStyleCrossDissolve,
        UIModalTransitionStylePartialCurl NS_ENUM_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED,
};

2、在主页面模态新页面时,需要隐藏底部的tabbar

ManagerForLinkVC *vc = [ManagerForLinkVC new];
            self.definesPresentationContext = YES;//self指的界面A
            vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
            vc.view.superview.frame = CGRectMake(0, 0, WIDTH, HEIGHT-TabbarHeight);//重新设置界面C的view的大小

模式的原文链接

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,262评论 4 61
  • 王子在城堡的南边修了一个小花园,那个花园里,什么美丽的花儿都能找到。传说,在那里,没有四季的约束,没有早晚的隔阂,...
    端木龙秀阅读 1,883评论 0 0
  • 很多时候喜欢独来独往,享受孤独,享受沉浸在自己的世界,做自己喜欢的事情,现代社会也让我们完全有能力有机会享受 一旦...
    傻不拉几fish阅读 242评论 0 0
  • 米赢文化阅读 141评论 0 0
  • 呜,小可怜 你像清晨回家受了伤的小猫 在床边涩涩发抖 别害怕 你那柔的掉进谷底的声音我已听见 我知道 你需要一个温...
    满_3539阅读 299评论 0 2