title: UITextField being clipped during CABasicAnimation with keyPath of bounds.size.width
body: <p>I have a somewhat of an odd issue on hand. I have UITextField. This TextField has it’s width resized when a button is tapped. To do that I first did the following:</p>
  
  <pre><code>CGRect newbounds = originalBounds;
  newbounds.size.width = newbounds.size.width/2;
  
  [UIView beginAnimations:nil context:nil];
  self.textField2.bounds = newbounds;
  [UIView commitAnimations];
  </code></pre>
  
  <p>Easy enough and it worked. Now I move along and try to exert a bit more control over the animation. To do that I go the next level up to CABasicAnimation using the following:</p>
  
  <pre><code>CGRect newbounds = originalBounds;
  newbounds.size.width = newbounds.size.width/2;
  
  CABasicAnimation *animShrink = [CABasicAnimation animation];
  animShrink.keyPath = @"bounds";
  animShrink.toValue = [NSValue valueWithCGRect:newbounds];
  animShrink.duration = 0.5;
  animShrink.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  animShrink.delegate = self;
  
  [self.textField2.layer addAnimation:animShrink forKey:@"shrink"];
  </code></pre>
  
  <p>And that is when I run into the clipping issue during the animation as can be seen at: <a href="http://coldstorage.macbonsai.com/public/cabasic_animation_clipping.png" rel="nofollow">http://coldstorage.macbonsai.com/public/cabasic_animation_clipping.png</a> (since I “need at least 10 reputation to post images” as per Stackoverflow).</p>
  
  <p>So I tried the following version of the animation:</p>
  
  <pre><code>CGRect newbounds = originalBounds;
  newbounds.size.width = newbounds.size.width/2;
  
  CABasicAnimation *animShrink = [CABasicAnimation animation];
  animShrink.keyPath = @"bounds.size.width";
  animShrink.fromValue = [NSNumber numberWithFloat:originalBounds.size.width];
  animShrink.toValue = [NSNumber numberWithFloat:newbounds.size.width];
  animShrink.duration = 0.5;
  animShrink.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  animShrink.delegate = self;
  
  [self.textField2.layer addAnimation:animShrink forKey:@"shrink"];
  </code></pre>
  
  <p>Still encountered the same issue. At this point I removed all constraints from the UITextField and tried both the CABasicAnimation versions. Same issue. At this point I don’t know what else to do. Any help will be greatly appreciated.</p>
  
  <p>Many thanks in advance.</p>