2014-03-04 14 views
1

我想在无影响的情况下动画化图像的移动。要正常动画的话,我可以使用:iOS - 动画无影响的图像移动

[UIView animateWithDuration:2.5f animations:^{ 
    CGRect currentFrame=self.image.frame; 
    currentFrame.origin.x-=10; 

    [self.image setFrame:currentFrame]; 

}]; 

然而,我发现,如果使用这种方法,图像逐渐加快,进入快一点,再逐渐停下来。

是否有任何方法来动画UIImageView的运动,保持视图在整个时间相同的速度?

回答

1

由于您的动画使用“自然”UIViewAnimationOptionCurveEaseInOut曲线,因此您的动画会加速并减速。使用UIViewAnimationOptionCurveLinear选项可以使用定速运动:

[UIView animateWithDuration:2.5f 
    delay:0 
    options:UIViewAnimationOptionCurveLinear 
    animations:^{ 
     CGRect currentFrame=self.image.frame; 
     currentFrame.origin.x-=10; 
     [self.image setFrame:currentFrame]; 
    } 
    completion:^(BOOL finished){ 
    } 
]; 
0
[UIView animateWithDuration:1.0 delay:0.0 options:0 animations:^{ 

} completion:^(BOOL finished) { 

}]; 
+0

尽量避免代码只能答案......虽然这是正确的,有人看它会有什么线索代码的功能。 – Jojodmo