There are a few examples out there that utilises animateWithDuration - are there any simple examples on how to use this function to move an image from point A to B ?
Asked
Active
Viewed 335 times
4 Answers
2
Quick and dirty just to show it in use
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

Paul.s
- 38,494
- 5
- 70
- 88
0
The following code can be used for animating objects.
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

Mission_Lennie
- 45
- 5