title: How to display an container view with animation in iOS?
body: <p>I want to display my own custom view when an user taps an button in the original view controller, and so I tried to define the following function which is caused when the user taps the button:</p>
  
  <pre><code>func show() {
      vc = UIViewController()
      var button = UIButton(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
      button.backgroundColor = UIColor.redColor()
      button.addTarget(self, action: "hide", forControlEvents: UIControlEvents.TouchDown)
      vc.view.addSubview(button)
  
      self.addChildViewController(vc)
      self.view.addSubview(vc.view)
      vc.didMoveToParentViewController(self)
  }
  </code></pre>
  
  <p>When the user taps the button however, the container view is displayed on the screen abruptly, but I want to make it shown more smoothly. So next I tried to rewrite it with animation, but I've hit the wall, since I don't know what I should write in order to display it with animation:</p>
  
  <pre><code>transitionFromViewController(self, toViewController: vc, duration: 0.5, options: UIViewAnimationOptions.TransitionCrossDissolve, animations: {() -&gt; Void in
          self.addChildViewController(self.vc)
          self.view.addSubview(self.vc.view)
          }, completion: {
          Bool -&gt; Void in
          self.vc.didMoveToParentViewController(self)
  })
  </code></pre>
  
  <p>This returns an error: <code>'NSInvalidArgumentException', reason: 'Children view controllers &lt;mmmmlvalsllsl.ViewController: 0x7fc980f71f70&gt; and &lt;UIViewController: 0x7fc980f6dd00&gt; must have a common parent view controller when calling -[UIViewController transitionFromViewController:toViewController:duration:options:animations:completion:]'</code>.</p>
  
  <p>I think I should use the method, but I don't know what code to write in <code>animations:</code> block and what to <code>completion:</code> block.</p>
  
  <p>How can I write the animation code?</p>