title: How to animate setFrame: with auto layout in Objective-C
body: <p>I'm working on an iOS (6) app, and I have a view, whose size I change (animated), and within that view is a UILabel, which I want to grow with the view, but not proportionally.</p>
  
  <p>i.e. I need the view to take up, say 90% of the view if the view is a certain size, but when I make it bigger (to another certain size), I only want it to take up, say 80%. This is to accommodate other subviews around the UILabel that will become visible when the super view grows.</p>
  
  <p>I have tried using NSLayoutContraints with this, and setting the leading space to what it needs to be, as well as setting the width of the UILabel to get it to grow appropriately, and I have also tried with settings the leading and trailing spaces (as the width would then automatically grow).</p>
  
  <p>Oddly, I have other subviews whose NSLayoutContraints I am playing with, in the same animation code block (using the UIView animateWithDuration:...) and they all work. All of these, however are spacing constraints, and not size constraints, and none involve UILabels so I dont know if this has anything to do with it...</p>
  
  <p>I then tried setting the UILabel's translatesAutoresizingMaskIntoConstraints = YES, and just using setFrame: on the label, and although this sets the size and position of the label exactly where I want it, the change is not animated, so it looks horrible...</p>
  
  <p>Has anybody else had experience with anything like this or any ideas to help me out?</p>
  
  <p>Thanks</p>
  
  <p>Following is some code I have been trying with, where "left" is the leading space constraint of the label and "width" is the width constraint of the label.</p>
  
  <p>The setFrame method is called within an animate code block from the parent view controller.</p>
  
  <pre><code>- (void)setFrame:(CGRect)frame {
      [super setFrame:frame];
  
      float gap = ((frame.size.height - 36) - 9 * [self.account.accountData numberOfBars]) / ([self.account.accountData numberOfBars] + 1);
      for (NSLayoutConstraint *constraint in constraints) {
          constraint.constant = gap;
      }
  
      self.left.constant = frame.size.width * 34/160 + (2 - 34 * 140 / 160);
      self.width.constant = frame.size.width * 0.575 + 55.5;
  
      [self layoutIfNeeded];
  
  }
  </code></pre>