当我调用此方法时:
- (void)method:(int)i {
while (image[i].center.y <= 100) {
image[i].center = CGPointMake(image[i].center.x, image[i].center.y+2);
}
}
循环立即运行,图像立即到达y = 100的位置。有没有一种方法可以减慢此速度(或我不知道的替代方法),使图像在视觉上移动或加速到一定程度,而不是立即移动到该点?
最佳答案
好像您要制作动画,也许像这样。
- (void)method:(int)i {
[UIView animateWithDuration:2.0
animations:^{
image[i].center = CGPointMake(image[i].center.x, 100);
}];
}
我建议你读这个
http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/animatingviews/animatingviews.html
关于objective-c - 减慢正在移动 ImageView 的while循环,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11248831/