3

i was wondering how do i animate things in apple's new language swift.

in objective c i would use the following code to move an image from the top of the screen to the end :

  [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
    UIImageView.center = CGPointMake(UIImageView.center.x , UIImageView.center.y + 200);
} completion:^(BOOL finished) {
    [self move];
}]; 

so the questoin is:

  • how do i animate stuff in swift with the same effect that the code above(obj c)has, i would appreciate some explaination about the way you can do that aswell.
  • have you ever read this https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIView_class/index.html#//apple_ref/occ/clm/UIView/animateWithDuration:delay:options:animations:completion:? if not, please read it first; if yes, what have your tried do far? – holex Jun 08 '14 at 11:20

1 Answers1

9
UIView.animateWithDuration(1, delay: 0, options: .CurveLinear, animations: {
    UIImageView.center = CGPointMake(UIImageView.center.x, UIImageView.center.y + 200);
}, completion: {
    (finished: Bool) in
    move();
});

This is how.