如何在Swift(Xcode 6 beta)中制作动画效果

3
我想知道如何在苹果的新语言Swift中制作动画。
在Objective-C中,我会使用以下代码将图像从屏幕顶部移动到底部:
  [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
    UIImageView.center = CGPointMake(UIImageView.center.x , UIImageView.center.y + 200);
} completion:^(BOOL finished) {
    [self move];
}]; 

所以问题是:

  • 我如何使用Swift实现与上面的Objective-C代码相同的动画效果?我也希望能够得到一些关于如何实现的解释。

你有没有读过这个链接 https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIView_class/index.html#//apple_ref/occ/clm/UIView/animateWithDuration:delay:options:animations:completion? 如果没有,请先阅读一下;如果有,那么你到目前为止尝试了什么? - holex
1个回答

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

这就是方法。

@AbdullahOssamaOmari 没问题,兄弟。 - user2742371

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接