modal的样式及 半透明控制器效果

modal出半透明的控制器:

    UIViewController * maskVC = [[UIViewController alloc] init];

    

    //设置页面的透明度

    maskVC.view.backgroundColor = [UIColor colorWithFullRed:0 green:0 blue:0 alpha:0.4];

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {

        maskVC.providesPresentationContextTransitionStyle = YES;

        maskVC.definesPresentationContext = YES;

        maskVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;

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

    } else {

        self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;

        [self presentViewController:maskVC animated:NO completion:nil];

        self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;

    }

  • 什么叫呈现样式
  • Modal出来的控制器,最终显示出来的样子
  • Modal常见有5种呈现样式
  • UIModalPresentationFullScreen :全屏显示(默认)
  • UIModalPresentationPageSheet
  • 宽度:竖屏时的宽度(768)
  • 高度:当前屏幕的高度(填充整个高度)
  • UIModalPresentationFormSheet :占据屏幕中间的一小块
  • UIModalPresentationCurrentContext :跟随父控制器的呈现样式
  • UIModalPresentationPopover:被popover包装过的样式
  •  
  •  
  • 什么叫过渡样式
  • Modal出来的控制器,是以怎样的动画呈现出来
  • Modal一共4种过渡样式
  • UIModalTransitionStyleCoverVertical :从底部往上钻(默认)
  • UIModalTransitionStyleFlipHorizontal :三维翻转
  • UIModalTransitionStyleCrossDissolve :淡入淡出
  • UIModalTransitionStylePartialCurl :翻页(只显示部分,使用前提:呈现样式必须是UIModalPresentationFullScreen)
  •  

 

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    

    UIViewController *vc = [[UIViewController alloc] init];

    vc.view.backgroundColor = [UIColor yellowColor];

    

    /*modal呈现样式-->iPhone中不起作用

     UIModalPresentationFullScreen = 0,

     UIModalPresentationPageSheet NS_ENUM_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED,

     UIModalPresentationFormSheet NS_ENUM_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED,

     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) __TVOS_PROHIBITED,

     UIModalPresentationNone NS_ENUM_AVAILABLE_IOS(7_0) = -1,

     */

    vc.modalPresentationStyle = UIModalPresentationFormSheet;//呈现样式

    

    

    /*modal的过渡样式

     UIModalTransitionStyleCoverVertical = 0,

     UIModalTransitionStyleFlipHorizontal __TVOS_PROHIBITED,

     UIModalTransitionStyleCrossDissolve,

     UIModalTransitionStylePartialCurl

     */

    vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

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

    

}

 

 

转载于:https://my.oschina.net/biyu6/blog/682050

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值