减慢正在移动图像视图的循环

Con*_*lor 2 cocoa-touch objective-c while-loop

当我调用这个方法时:

- (void)method:(int)i {
    while (image[i].center.y <= 100) {
        image[i].center = CGPointMake(image[i].center.x, image[i].center.y+2);
    }
}
Run Code Online (Sandbox Code Playgroud)

循环立即运行,图像立即进入y = 100的点.有没有办法减慢这个(或者我不知道的另一种选择),让图像在视觉上移动或加速到点,而不是立即移动到它?

epa*_*tel 7

看起来你想制作动画,也许是这样的.

- (void)method:(int)i {
   [UIView animateWithDuration:2.0
                    animations:^{ 
                      image[i].center = CGPointMake(image[i].center.x, 100);
                    }];
}
Run Code Online (Sandbox Code Playgroud)

我建议你读这个

http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/animatingviews/animatingviews.html