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

}

 

 

posted @ 2014-10-30 14:01  菜鸟程序猿  阅读(729)  评论(0编辑  收藏  举报