title: Embedding subview in main view Swift
body: <p>If you look at <a href="http://kb.xcentric.com/images/ipad12.jpg" rel="nofollow noreferrer">this image</a> (I don't want to upload it, as it does not belong to me), you will see what appears to be a uiview inside the main uiview controller in the settings app of an iPad. My question is, how do I replicate this programatically? In other words, how do I embed a UIView in another?</p>
  
  <p>Here's what I know and have done:</p>
  
  <ul>
  <li>Based on my research, this is called "subviews". Is this correct?</li>
  <li>I have created a UIView with the proper elements that I want in interface builder. It is currently not a subview, but at the same level hierarchically as my main view.</li>
  <li>I found the <a href="https://stackoverflow.com/questions/3994174/how-can-i-add-a-uiview-as-a-subview-of-uiviewcontroller-when-a-button-clicked">same exact question</a> except in Obj-C, not my language (Swift).</li>
  </ul>
  
  <p>Here's what I need:</p>
  
  <ul>
  <li>How do I programatically spawn a subview in swift once a button is clicked?</li>
  <li>As this subview is pretty complex in terms of UIelements, I want to be able to design it in interface builder.</li>
  </ul>
  
  <p>Here's what I have so far:</p>
  
  <pre><code> @IBAction func buttonPressedSpawnSubview(sender: AnyObject) {
      //Open a subview from Interface builder.
  }
  @IBAction func closeButtonPressedSpawnSubview(sender: AnyObject) {
          //kill the subview.
  </code></pre>
  
  <p>Can someone help me figure out how fill in the commented lines?</p>