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

}

 
原文地址:https://www.cnblogs.com/joesen/p/4062533.html