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

modal出半透明的控制器:ide

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

    

    //设置页面的透明度url

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

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

        maskVC.providesPresentationContextTransitionStyle = YES;it

        maskVC.definesPresentationContext = YES;io

        maskVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;event

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

    } else {float

        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];

    

}

相关文章
相关标签/搜索