title: UILabel animation beyond bounds of UILabel
body: <p>I have a label and I want a "speedometer" effect; when a new value is assigned to the label's text I'd like the old value to scroll up and the new to come in from below.  I am agnostic as to how to achieve this.  This is what I am using currently;</p>
  
  <pre><code>  CATransition *animation = [CATransition animation];
    animation.duration = .2f;
    animation.type = kCATransitionPush;
    animation.subtype = kCATransitionFromBottom;
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    animation.removedOnCompletion = YES;
  
    [mylabel.layer addAnimation:animation
                         forKey:@"changeTextTransition"];
  
    mylabel.text = @"new text";
  </code></pre>
  
  <p>This works pretty dang well EXCEPT that the transition at top and bottom goes outside the bounds of the label before fading.  I'd like the transition effect to be contained within the bounds of the label.</p>
  
  <p>I have tried to create a mask for the layer, and have the layer mask to bounds, but this had no effect:</p>
  
  <pre><code>  UIImageView *maskView = [[UIImageView alloc] initWithImage:labelMask];
    // this image is a png that is the same dimensions as the label, and is 100% opaque and colored white
    maskView.frame = mylabel.frame;
    mylabel.layer.mask = maskView.layer;
    mylabel.layer.masksToBounds = YES;
  </code></pre>
  
  <p>I even tried an alternate method of mask creation:</p>
  
  <pre><code>  CALayer *maskLayer = [CALayer new];
    maskLayer.frame = mylabel.frame;
    maskLayer.contents = (id)(labelMask.CGImage); // same image as above
    maskLayer.contentsRect = mylabel.bounds;
    mylabel.layer.mask = maskLayer;
    mylabel.layer.masksToBounds = YES;
  </code></pre>
  
  <p>This had no effect.</p>
  
  <p>What else may I try to prevent the layer animation from leaking past the bounds of the UILabel?</p>