【发布时间】:2015-02-27 11:45:25
【问题描述】:
我正在Swift 制作我的第一款游戏,我想知道如何在用户按下按钮时为 Z 位置(或缩小和放大)的按钮设置动画。
虽然我找到了答案,但我找到的所有内容都写在 Objective-C 中,而且由于我是编码新手,所以我很难将 Obj-C 翻译成 Swift。
这是我发现的:
UIButton *button = (UIButton*)sender;
//animates button 25 pixels right and 25 pixels down. Customize
CGRect newFrame = CGRectMake(button.frame.origin.x + 25, button.frame.origin.y + 25, button.frame.size.width, button.frame.size.height);
[UIView animateWithDuration:0.3f
delay:0.0f
options: UIViewAnimationOptionCurveLinear
animations:^{
[button setFrame:newFrame];
}
completion:nil];
【问题讨论】:
-
你有什么问题?
-
好吧,我不知道它在 Obj-C 中的含义,所以我正在寻找可以帮助我将其翻译成 swift 的人,以便我可以在我的代码中实现它。
标签: ios animation swift uibutton jquery-animate