title: Issue with Layout Horizontal Anchors - Swift 3
body: <p>Can anyone provide insight on why my code isn't working?</p>
  
  <p>I'm trying to add horizontal spacing between the 2 views in the picture (Red and Black one) but for some reason I keep getting that error and I'm not sure how to fix it.</p>
  
  <p>I'm assuming the other constraints are working correctly since I'm not seeing any issues, nor in the simulation or in the console.</p>
  
  <p><a href="https://i.stack.imgur.com/yVSHu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yVSHu.jpg" alt="enter image description here"></a></p>
  
  <p>Code as requested by user: <a href="https://gist.github.com/sungkim23/66ecd9ce71d0480f083bcd05caf0a58c" rel="nofollow noreferrer">https://gist.github.com/sungkim23/66ecd9ce71d0480f083bcd05caf0a58c</a></p>
  
  <pre><code>import UIKit
  
  class BuyButton: UIView {
  
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
  
          //MARK: - View
          backgroundColor = UIColor(red: 180/255, green: 35/255, blue: 115/255, alpha: 1)
          layer.cornerRadius = 3
  
          //MARK: - Price View
          let priceView = UIView(frame: CGRect(x: 0, y: 0, width: 80, height: bounds.size.height))
          priceView.backgroundColor = UIColor.black
          addSubview(priceView)
  
          //MARK: - Purchase View
          let purchaseView = UIView(frame: CGRect(x: 80, y: 0, width: bounds.size.width - 80, height: bounds.size.height))
          purchaseView.backgroundColor = UIColor.red
          addSubview(purchaseView)
  
          //MARK: - Price Label
          let priceLabel = UILabel(frame: CGRect.zero)
          priceLabel.text = "$ 50.00"
          priceLabel.textAlignment = .center
          priceLabel.backgroundColor = .red
          priceLabel.translatesAutoresizingMaskIntoConstraints = false
          priceView.addSubview(priceLabel)
  
          //MARK: - Purchase Label
          let purchaseLabel = UILabel(frame: CGRect.zero)
          purchaseLabel.text = "Purchase"
          purchaseLabel.textAlignment = .center
          purchaseLabel.backgroundColor = .green
          purchaseLabel.translatesAutoresizingMaskIntoConstraints = false
          purchaseView.addSubview(purchaseLabel)
  
          //MARK: - View Constraints
          priceView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
          priceView.topAnchor.constraint(equalTo: topAnchor).isActive = true
          priceView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
  
          purchaseView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
          purchaseView.topAnchor.constraint(equalTo: topAnchor).isActive = true
          purchaseView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
  
          priceView.centerXAnchor.constraint(equalTo: purchaseView.centerXAnchor).isActive = true
  
          //MARK: - Label Constraints
          priceLabel.centerXAnchor.constraint(equalTo: priceView.centerXAnchor).isActive = true
          priceLabel.centerYAnchor.constraint(equalTo: priceView.centerYAnchor).isActive = true
          purchaseLabel.centerXAnchor.constraint(equalTo: purchaseView.centerXAnchor).isActive = true
          purchaseLabel.centerYAnchor.constraint(equalTo: purchaseView.centerYAnchor).isActive = true
  
          //MARK: - Constraint priorities
  
      }
  }
  </code></pre>
  
  <p>UPDATE 1 - Added error to question as requested</p>
  
  <pre><code>2017-03-13 11:02:38.440892 ButtonTest[20954:1645749] [LayoutConstraints] Unable to simultaneously satisfy constraints.
  Probably at least one of the constraints in the following list is one you don't want. 
  Try this: 
      (1) look at each constraint and try to figure out which you don't expect; 
      (2) find the code that added the unwanted constraint or constraints and fix it. 
  (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
  (
  "&lt;NSAutoresizingMaskLayoutConstraint:0x60000009a400 h=--&amp; v=--&amp; UIView:0x7fe55be017b0.midX == 40   (active)&gt;",
  "&lt;NSAutoresizingMaskLayoutConstraint:0x600000099ff0 h=--&amp; v=--&amp; UIView:0x7fe55bc09310.midX == 232   (active)&gt;",
  "&lt;NSLayoutConstraint:0x600000099c30 UIView:0x7fe55be017b0.centerX == UIView:0x7fe55bc09310.centerX   (active)&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x600000099c30 UIView:0x7fe55be017b0.centerX ==    UIView:0x7fe55bc09310.centerX   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to   catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.
  </code></pre>
  
  <p>UPDATE 2 - tl;dr</p>
  
  <p>Use<br>
  yourView.leadingAnchor.constraint(equalTo: yourOtherView.trailingAnchor).isActive = true</p>
  
  <p>instead of </p>
  
  <p>yourView.centerXAnchor.constraint(equalTo: yourOtherView.centerXAnchor).isActive = true</p>