iOS加密算法iOS-UI布局

UIModalPresentationStyle和UIModal

2017-11-14  本文已影响387人  小如99
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,
};

代码如下:

- (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,要不然没有透明背景的效果

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

上一篇下一篇

猜你喜欢

热点阅读