Reputation: 3108
When I call this method:
- (void)method:(int)i {
while (image[i].center.y <= 100) {
image[i].center = CGPointMake(image[i].center.x, image[i].center.y+2);
}
}
The loop instantly runs and the image is instantly brought to the point where y=100. Is there a way of slowing this (or an alternative I am unaware of) that will let the image visually move or accelerate to the point rather that instantly moving to it?
Upvotes: 2
Views: 213
Reputation: 6803
Try using code similar to this:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
image.center = CGPointMake(image.center.x, image.center.y-moveAmount);
[UIView commitAnimations];
Upvotes: 2
Reputation: 46051
It seems like you are looking to make an animation, maybe something like this.
- (void)method:(int)i {
[UIView animateWithDuration:2.0
animations:^{
image[i].center = CGPointMake(image[i].center.x, 100);
}];
}
I recommend you read this
Upvotes: 7