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

Objective c 减慢正在移动图像视图的while循环,objective-c,cocoa-touch,while-loop,Objective C,Cocoa Touch,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); } } -(void)方法:(int)i{ while(image[i].center.y看起来你想制作一个动画,可能是这样的 - (void)method:(int)i {

当我调用此方法时:

- (void)method:(int)i {
    while (image[i].center.y <= 100) {
        image[i].center = CGPointMake(image[i].center.x, image[i].center.y+2);
    }
}
-(void)方法:(int)i{

while(image[i].center.y看起来你想制作一个动画,可能是这样的

- (void)method:(int)i {
   [UIView animateWithDuration:2.0
                    animations:^{ 
                      image[i].center = CGPointMake(image[i].center.x, 100);
                    }];
}
我建议你读一下这个


尝试使用类似以下代码:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
image.center = CGPointMake(image.center.x, image.center.y-moveAmount);
[UIView commitAnimations];