title: Programmatically adding constraints in Swift does not work
body: <p>I added the following code to center a programmatically added view:</p>
  
  <pre><code>let horizontalConstraint = NSLayoutConstraint(item: newView!, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0)
  view.addConstraint(horizontalConstraint)
  </code></pre>
  
  <p>It doesn't work. The view is not centered. It is on the left still.</p>
  
  <p>EDIT:</p>
  
  <pre><code>    override func viewDidLoad() {
      super.viewDidLoad()
  
      newView = LineChartView(frame: CGRectMake(0, 0, 50, 50))
      newView?.delegate = self
      newView?.drawBordersEnabled = true
      newView?.noDataText = "No Data"
      newView?.noDataTextDescription = "No Data"
      newView?.borderColor = UIColor.blackColor()
  
      self.view.addSubview(newView!)
  </code></pre>