title: Display clearColor UIViewController over UIViewController
body: <p>I have a <code>UIViewController</code> view as a subview/modal on top of another <code>UIViewController</code> view, such as that the subview/modal should be transparent and whatever components is added to the subview should be visible. The problem is that I have is the subview shows black background instead to have clearColor. I'm trying to make <code>UIView</code> as a clearColor not black background. Does anybody know what is wrong with it? Any suggestion appreciated.</p>
  
  <p><strong>FirstViewController.m</strong></p>
  
  <pre><code>UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
  UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
  
  [vc setModalPresentationStyle:UIModalPresentationFullScreen];
  [self presentModalViewController:vc animated:NO];  
  </code></pre>
  
  <p><strong>SecondViewController.m</strong></p>
  
  <pre><code>- (void)viewDidLoad 
  {
       [super viewDidLoad];
       self.view.opaque = YES;
       self.view.backgroundColor = [UIColor clearColor];
  }
  </code></pre>
  
  <hr>
  
  <p><strong>RESOLVED</strong>: I fixed the issues. It is working so well for both of iPhone and iPad. Modal View Controller with no black background just clearColor/transparent. The only thing that I need to change is I replaced <code>UIModalPresentationFullScreen</code> to <code>UIModalPresentationCurrentContext</code>. How simple is that!</p>
  
  <p><strong>FirstViewController.m</strong></p>
  
  <pre><code>UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
  UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
  vc.view.backgroundColor = [UIColor clearColor];
  self.modalPresentationStyle = UIModalPresentationCurrentContext;
  [self presentViewController:vc animated:NO completion:nil];
  </code></pre>
  
  <hr>
  
  <p><strong>NOTICE:</strong> If you are using a <code>modalPresentationStyle</code> property of <code>navigationController</code>:</p>
  
  <p><strong>FirstViewController.m</strong></p>
  
  <pre><code>UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
  UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
  vc.view.backgroundColor = [UIColor clearColor];
  self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
  [self presentViewController:vc animated:NO completion:nil];
  </code></pre>
  
  <hr>
  
  <p><strong>NOTICE: The bad news is that the above solution doesn't work on iOS 7. The good news is that I fixed the issue for iOS7! I asked somebody for help and here is what he said:</strong></p>
  
  <p><em>When presenting a view controller modally, iOS removes the view controllers underneath it from the view hierarchy for the duration it is presented.  While the view of your modally presented view controller is transparent, there is nothing underneath it except the app window, which is black.  iOS 7 introduced a new modal presentation style, <code>UIModalPresentationCustom</code>, that causes iOS not to remove the views underneath the presented view controller. However, in order to use this modal presentation style, you must provide your own transition delegate to handle the presentation and dismiss animations.  This is outlined in the 'Custom Transitions Using View Controllers' talk from WWDC 2013 <a href="https://developer.apple.com/wwdc/videos/?id=218" rel="noreferrer">https://developer.apple.com/wwdc/videos/?id=218</a> which also covers how to implement your own transition delegate.</em> </p>
  
  <p>You may see my solution for the above issue in iOS7: <a href="https://github.com/hightech/iOS-7-Custom-ModalViewController-Transitions" rel="noreferrer">https://github.com/hightech/iOS-7-Custom-ModalViewController-Transitions</a></p>