title: Change AutoLayout Constraints during Run Time
body: <p>How is it possible to change AutoLayout Constraints during run time.</p>
  
  <p>I need to change the coordinate of view during run time so i did following:</p>
  
  <pre><code> if ([OfferText length] != 0) {
              cell.topContentView.translatesAutoresizingMaskIntoConstraints = YES;
              CGRect newFrame = CGRectMake( 71, 4, [Util window_width]-71,50);
              cell.topContentView.frame = newFrame;
          }
  </code></pre>
  
  <p>While doing that I get following warning. Is it possible to change the auto layout constraints during run time.</p>
  
  <pre><code>(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;NSLayoutConstraint:0x7fca729606a0 UIView:0x7fca7296c6e0.top == UITableViewCellContentView:0x7fca729712b0.topMargin + 2&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x7fca7286f620 h=--&amp; v=--&amp; UIView:0x7fca7296c6e0.midY == + 29&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x7fca7286f670 h=--&amp; v=--&amp; V:[UIView:0x7fca7296c6e0(50)]&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x7fca705c9770 h=--&amp; v=--&amp; 'UIView-Encapsulated-Layout-Top' V:|-(0)-[UITableViewCellContentView:0x7fca729712b0]   (Names: '|':CollectionBrandCell:0x7fca72968820 )&gt;"
  )
  </code></pre>
  
  <p>I find my solution using following code:</p>
  
  <p><strong>in .h</strong>  of tableviewcell In my case</p>
  
  <pre><code>@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintsTopContentView;
  </code></pre>
  
  <p>and <strong>in .m</strong> </p>
  
  <pre><code>if ([OfferText length] != 0) {
              cell.constraintsTopContentView.constant=-4;
          }
  </code></pre>