title: UIView corner radius animation
body: <p>I have some class for UIButton like this :</p>
  
  <pre><code>@implementation UIRoundButton
  
  - (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self) {
          [self.layer setCornerRadius:self.frame.size.width/2];
      }
      return self;
  }
  
  - (id)initWithCoder:(NSCoder *)aDecoder
  {
      self = [super initWithCoder:aDecoder];
      if (self) {
          [self.layer setCornerRadius:self.frame.size.width/2];
      }
      return self;
  }
  
  - (void) layoutIfNeeded
  {
      [super layoutIfNeeded];
      [self.layer setCornerRadius:self.frame.size.width/2];
  }
  </code></pre>
  
  <p>So it create rounded button and change corner radius for auto layout.</p>
  
  <p>But my problem is when I want to do animation like this : </p>
  
  <pre><code>[UIView animateWithDuration:0.6 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
  
  
      self.deleteButton.alpha = 1;
  
      self.buttonHeight.constant = 40;
      self.buttonWidth.constant = 40;
  
      [self layoutIfNeeded];
  
  } completion:^(BOOL finished) {
      [UIView animateWithDuration:0.6 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
  
          self.deleteButton.alpha = 0;
  
          self.buttonHeight.constant = 16;
          self.buttonWidth.constant = 16;
  
          [self layoutIfNeeded];
  
      } completion:^(BOOL finished) {
  
      }];
  }];
  </code></pre>
  
  <p>So I change width and height for this button. The problem is that corner radius does not change properly. Why? It should call layoutIfNeeded method and change it.</p>
  
  <p>Marko</p>
  
  <p>EDIT : </p>
  
  <p>This means that before animation the button has width and height 16. I animate to be 40. But the corners are through all animation 8 px. Then on the end animations I animate again from width value 40 to width value 16, now the corner radius is 20 px through all animation. Like it would call layoutIfNeeded onelly at the end of animations</p>