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

    

}

相關文章
相關標籤/搜索