首页 > 代码库 > 在iOS上present一个半透明的viewController

在iOS上present一个半透明的viewController

UIViewController *viewController = [[UIViewController alloc]init];UIViewController* controller = self.view.window.rootViewController;
viewController.view.backgroundColor
= [UIColor blackColor];viewController.view.alpha = 0.5f;controller.modalPresentationStyle = UIModalPresentationCurrentContext;[controller presentViewController:viewController animated:NO completion:nil];

UIViewController 页面

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGesture:)];

[self.view addGestureRecognizer:tapGesture];

 

- (void)tapGesture:(UITapGestureRecognizer *)gesture

{

    [self dismissViewControllerAnimated:YES completion:nil];

}

 

 

在iOS上present一个半透明的viewController