title: How to use UIBlurEffect with modal View Controllers?
body: <p>I have a <code>UIViewController</code> that presents another <code>UIViewController</code> modally. I want the modal view controller to have the blur/transparency that iOS 7 introduced. I tried using the new <code>UIVisualEffect</code> but it seems like that only works with <code>UIViews</code>, and not <code>UIViewControllers</code>?</p>
  
  <p>Here is the code I've written, all the views I've added as subviews are what I want to be in the user interface above the blurred out view below it.</p>
  
  <p>In the presenting view controller, I take a screenshot of the screen that I pass to the modal view controller before applying the blur.</p>
  
  <p><strong>In Presenting View Controller:</strong></p>
  
  <pre><code>- (UIImage *)viewImage {
      CGSize size = CGSizeMake(self.view.frame.size.width,self.view.frame.size.height);
      UIGraphicsBeginImageContext(size);
      [self.view drawViewHierarchyInRect:(CGRect){CGPointZero, self.view.frame.size.width, self.view.frame.size.height} afterScreenUpdates:YES];
      UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
  
      return image;
  }
  </code></pre>
  
  <p><strong>In Modal View Controller:</strong></p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
  
      [self.view addSubview:[[UIImageView alloc] initWithImage:self.backgroundImage]];
      //self.backgroundImage is the image that the method above returns, it's a screenshot of the presenting view controller.
      UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
      UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
      [blurEffectView setFrame:self.view.bounds];
      [self.view addSubview:blurEffectView];
  
      [self.view bringSubviewToFront:self.cancelButton];
      [self.view bringSubviewToFront:self.titleLabel];
      [self.view bringSubviewToFront:self.tableView];
  }
  </code></pre>