有几个例子使用animateWithDuration - 有没有关于如何使用这个函数将图像从A点移动到B的简单例子?如何在RubyMotion中使图像移动/动画?
0
A
回答
2
快速和肮脏只是为了显示它在使用
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame UIScreen.mainScreen.bounds
@window.makeKeyAndVisible
my_view = UIView.alloc.initWithFrame [[0, 0], [50, 50]]
my_view.backgroundColor = UIColor.greenColor
@window.addSubview my_view
UIView.animateWithDuration(0.25, animations: lambda {
new_frame = my_view.frame
new_frame.origin = [100, 100]
my_view.frame = new_frame
})
true
end
end
0
下面的代码可用于动画对象。
my_view = UIView.alloc.initWithFrame [[0, 0], [50, 50]]
my_view.backgroundColor = UIColor.greenColor
view.addSubview my_view
my_view.frame = [[0,0],[0,0]] #the position from which animation begins
UIView.beginAnimations(nil,context:nil)
UIView.setAnimationDuration(0.05)
UIView.setAnimationDelay(0.2)
UIView.setAnimationCurve(UIViewAnimationCurveEaseOut)
my_view.frame = [[250,400],[50,50]] # the position at which the animation ends
my_view.backgroundColor = UIColor.blueColor #you can also change other properties while animating
UIView.commitAnimations
0
使用sugarcube!
frame = my_view.frame
frame.origin = point_a
my_view.frame = frame
# animating the move to point_b is EASY
my_view.move_to point_b
0
你可能也想看看Walt。
{
move: "my_id",
from: [10, 10],
to: [50, 50]
}
相关问题
- 1. JavaFX移动图像动画
- 2. 使用CSS3动画移动图像
- 3. 移动画廊图像
- 4. 如何在将图像附加到动画时使用动画缓慢移动图像标记
- 5. Javascript-如何将图像自动移动到Photoshop中的画布?
- 6. 如何在RubyMotion中旋转图像?
- 7. 如何在视图中移动图像
- 8. Angualr 2动画:移动图像流畅
- 9. 基本核心动画 - 移动图像
- 10. Android图像移动动画问题
- 11. 如何在TitleBar中动画图像?
- 12. 如何在Swift中动画图像?
- 13. 如何在android中动画图像?
- 14. 如何在android中动画onDraw图像?
- 15. 如何让图像在画布中移动?
- 16. Android Studio如何动画移动视图?
- 17. 在Android上使用翻译动画移动图像的问题
- 18. Xcode,iphone - 使图像动画在特定方向移动
- 19. 如何使一个动画像一个移动的箭头图像
- 20. 如何在openGL ES中移动图像?
- 21. 如何在javascript中移动图像
- 22. 如何停止通过动画移动的图像?
- 23. 我如何动画自动上移的图像
- 24. Tkinter - 如何从慢动作画布移动图像
- 25. 在RubyMotion中使用Xcode图像目录
- 26. 在UIWebView中动画图像
- 27. 图像在VB6中移动和动画时闪烁
- 28. 图像在循环动画中移动 - Swift
- 29. 如何设置动画使用图像
- 30. 如何使用openlayers3动画图像png