title: Move and animate UIImageView using swift
body: <p>I have what should be a fairly simple question here. Basically I'm trying to move an object (a UIImageView) from a point A (where it is set in the storyboard) to a point B which I define programatically.</p>
  
  <p>My first pass through this resulted in this code</p>
  
  <pre><code>        UIView.animateWithDuration(0.75, delay: 0.5, options: UIViewAnimationOptions.CurveLinear, animations: {
              self.signInButton.alpha = 1
              self.signInButton.center.y = 10
          }, completion: nil)
  </code></pre>
  
  <p>However, what this code does is to basically move the button offcenter and then back to its original location.</p>
  
  <p>I then looked into QuartzCore to help me, but everything is in Objective-C. I have this method:</p>
  
  <pre><code>    func moveImage(view: UIImageView){
          var toPoint: CGPoint = CGPointMake(0.0, -10.0)
          var fromPoint : CGPoint = CGPointZero
  
          var movement = CABasicAnimation(keyPath: "movement")
          movement.additive = true
          movement.fromValue = fromPoint
          movement.toValue = toPoint
          movement.duration = 0.3
  
          view.layer.addAnimation(movement, forKey: "move")
      }
  </code></pre>
  
  <p>However the problem here is that <code>movement.fromValue</code> cannot accept a <code>CGPoint</code>. I know that in objective C there was a function that converted a <code>CGPoint</code> to a <code>NSValue</code>, however this function seems to be deprecated out of Swift and I can't find the other way of doing this. </p>
  
  <p><strong>Therefore my question is either, how do I convert <code>CGPoint</code> to <code>NSValue</code> to make my <code>moveImage()</code> function work, or is there a better way to move an object from point A to point B?</strong></p>
  
  <p>Thanks!</p>
  
  <p>I'm looking at this question <a href="https://stackoverflow.com/questions/12881150/animate-uiimage-in-uiimageview-up-down-like-its-hovering-loop">Animate UIImage in UIImageView Up &amp; Down (Like it&#39;s hovering) Loop</a> </p>