title: Percentage based margin using autolayout
body: <p>I'm trying to place my subview with a left margin based on the width of the parent view. This sounds simple but I can't figure out how to do it using autolayout.</p>
  
  <p>Logically, I would only need to set the left margin value at a certain percentage value of the parent's width but at the moment, I fail to translate that logic to autolayout.</p>
  
  <p>This is my code at the moment:</p>
  
  <pre><code>var view = UIView();
  view.backgroundColor = UIColor.redColor();
  view.frame = CGRectMake(0, 0, 320, 400);
  
  var sview = UIView();
  sview.setTranslatesAutoresizingMaskIntoConstraints(false);
  sview.backgroundColor = UIColor.yellowColor();
  //sview.frame = CGRectMake(0, 0, 50, 50);
  view.addSubview(sview);
  
  var dict = Dictionary&lt;String, UIView&gt;()
  dict["box"] = sview;
  
  var con1 = NSLayoutConstraint(item: sview, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Top, multiplier: 1.0, constant: 20.0);
  view.addConstraint(con1);
  
  var con2 = NSLayoutConstraint(item: sview, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Width, multiplier: 0.75, constant: 0.0);
  view.addConstraint(con2);
  
  var con3 = NSLayoutConstraint(item: sview, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Width, multiplier: 1.0, constant: 0.0);
  view.addConstraint(con3);
  
  var con4 = NSLayoutConstraint(item: sview, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Height, multiplier: 1.0, constant: 0.0);
  view.addConstraint(con4);
  </code></pre>
  
  <p>This is the where the code returns an error:</p>
  
  <pre><code>var con2 = NSLayoutConstraint(item: sview, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Width, multiplier: 0.75, constant: 0.0);
  view.addConstraint(con2);
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p><strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> +[NSLayoutConstraint
    constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]:
    Invalid pairing of layout attributes'</p>
  </blockquote>
  
  <p>Does anyone have any idea on how to achieve this? I just want the left margin to be 0.75% of the parent view's width.</p>
  
  <p>Thanks.</p>