UIModalPresentationStyle和UIModalTransitionStyle效果显示

UIModalPresentationStyle的样式解析
typedefNS_ENUM(NSInteger, 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的动画效果展示
typedef NS_ENUM(NSInteger, UIModalTransitionStyle) {
        UIModalTransitionStyleCoverVertical = 0,
        UIModalTransitionStyleFlipHorizontal __TVOS_PROHIBITED,
        UIModalTransitionStyleCrossDissolve,
        UIModalTransitionStylePartialCurl NS_ENUM_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED,
};
  • UIModalTransitionStyleCrossDissolve


    UIModalPresentationStyle和UIModalTransitionStyle效果显示_第1张图片
    UIModalTransitionStyleCrossDissolve.gif

代码如下:

- (void)ruleActionTrigged {

    NWFTipAlertController *alertVc = [[NWFTipAlertController alloc] initWithNibName:@"NWFTipAlertController" bundle:nil];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:alertVc];
    nav.navigationBarHidden = YES;
    nav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:nav animated:YES completion:nil];
}

 //NWFTipAlertController.m 文件

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
    }
    return self;
}

此处的只能用UIModalPresentationOverCurrentContext,要不然没有透明背景的效果

  • UIModalTransitionStyleCoverVertical


    UIModalPresentationStyle和UIModalTransitionStyle效果显示_第2张图片
    UIModalTransitionStyleCoverVertical.gif
  • UIModalTransitionStyleCrossDissolve


    UIModalPresentationStyle和UIModalTransitionStyle效果显示_第3张图片
    UIModalTransitionStyleCrossDissolve.gif
  • UIModalTransitionStyleFlipHorizontal


    UIModalPresentationStyle和UIModalTransitionStyle效果显示_第4张图片
    UIModalTransitionStyleFlipHorizontal.gif
  • UIModalTransitionStylePartialCurl


    UIModalPresentationStyle和UIModalTransitionStyle效果显示_第5张图片
    UIModalTransitionStylePartialCurl.gif

参考文章:
UIModalPresentationStyle即viewcontroller的显示方式
[iOS]modalPresentationStyle和modalTransitionStyle
UIModalPresentationStyle和UIModalTransitionStyle 浅谈

你可能感兴趣的:(UIModalPresentationStyle和UIModalTransitionStyle效果显示)