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