title: How do I create dynamic views in swift?
body: <p>I am making an IOS app where the main layout is a UITableView, and cells are completely dynamic and loaded from server. Each tableview item is a different layout.</p>
  
  <p>For example, lets take first item of the tableview:</p>
  
  <p>Server tells it should have a label, 2 buttons and a textbox, it should be created by code. I figured out how to create those elements themselves, the problem is how do I position them? </p>
  
  <p>Ideally I would like to add each layout item under the previous one. And tableviewcell should wrap those, grow or collapse according to views.</p>
  
  <p>I am fairly new to IOS/Swift. Is there any way to implment this easily? In android I just used a linearlayout and added views one by one. Does IOS have something like that? Or do I have to manually set heights, widths, and coordinates of all items?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Here is some code:</p>
  
  <pre><code>if let Actions = AppData["Forms"][0]["AvailableActions"].array{
                  for var i = 0 ; i &lt; Actions.count ; ++i {
                      if Actions[i].int == 1{
                          let actionButton1 = UIButton(frame: CGRectMake(0, 0, 96, 30))
                          actionButton1.setTitle("View", forState: .Normal)
                          actionButton1.setTitleColor(UIColor.redColor(), forState: .Normal)
                          cell.actionsLayout.addSubview(actionButton1)
                      }
                  }
              }
  </code></pre>