Search code examples
xcodeswiftnstimer

Example of using NSTimer to move an Image?


Can anyone provide and example of how to use the NSTImer to move a UIImageView on Swift? I realize using animations ins the preferred method, but I can't get it to move smoothly and in the right coordinates. This is using xcode 7. Thanks

ATTENTION!!

I have edited and responded to Jacob to see further problem solving.


Solution

  • As mentioned in the comments I don't really think you want to use an NSTimer for this type of thing.

    Have you tried:

    UIView.animateWithDuration(0.2, animations: {
         //update frame of imageView to new desired location
    }, completion: {
         //
    })