title: How to change layout constraint programmatically in Swift?
body: <p>I have a collection view which has a textView for each cell. This is my textview constraint set up</p>
  
  <pre><code>textView.topAnchor.constraint(equalTo: object1.bottomAnchor).isActive = true
  textView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
  </code></pre>
  
  <p>...and width and height of my textView.</p>
  
  <p>Now, I want to change topAnchor of my textView to object 2 bottom anchor instead of object 1 bottom anchor due to a if condition. However, when I enter the code below, I get 
  Will attempt to recover by breaking constraint error. </p>
  
  <p>Does anyone know a way to change top anchor once it is already set up?</p>
  
  <pre><code>if (aCondition){
  textView.topAnchor.constraint(equalTo: object2.bottomAnchor).isActive = true
  }else{
    textView.topAnchor.constraint(equalTo: object1.botttomAnchor).isActive = true
  }
  </code></pre>