title: Animating UILabel element with CoreAnimation in Swift
body: <p>I'm learning how to use CoreAnimation with various UI elements. Ultimately I would like to perform complex, queued animations on all ui elements on screen as I transition to the next view.</p>
  
  <p>Now however I am attempting something really simple. I want to transform (scale up) a UILabel on button tap.</p>
  
  <p>I have the following function:</p>
  
  <pre><code>func animateUIElementsOut(element : AnyObject) {
  
    var animation : CABasicAnimation = CABasicAnimation(keyPath: "transform");
  
    var transform : CATransform3D = CATransform3DMakeScale(2, 2, 1);
  
    animation.setValue(NSValue(CATransform3D: transform), forKey: "scaleText");
  
    animation.duration = 2.0;
  
    element.layer?.addAnimation(animation, forKey: "scaleText");
  
  }
  </code></pre>
  
  <p>I am calling the function on a button tap like this:</p>
  
  <pre><code>  animateUIElementsOut(greetingsLabel);
  </code></pre>
  
  <p>The compiler isn't giving off any warnings, however the animation is  not working. What am I doing wrong here?</p>
  
  <p>As per @David Rönnqvist suggestions the working code looks like this (fromValue / toValue added):</p>
  
  <pre><code>func animateUIElementsOut(element : AnyObject) {
  
    var animation : CABasicAnimation = CABasicAnimation(keyPath: "transform");
  
    animation.delegate = self;
  
    var transform : CATransform3D = CATransform3DMakeScale(2, 2, 1);
  
    animation.fromValue = NSValue(CATransform3D: CATransform3DIdentity);
    animation.toValue = NSValue(CATransform3D: transform);
  
    animation.duration = 2.0;
  
    element.layer?.addAnimation(animation, forKey: nil);
  }
  </code></pre>