我想动画我的多重UIImageViews从点A到点B线性移动。
我正在使用options:UIViewAnimationOptionCurveLinear - Apple说:“线性动画曲线会使动画在其持续时间内均匀地发生。”
下面是我正在使用的代码:
[UIView animateWithDuration:1.5
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
//start animation of random grasses with const speed and const y
for (int i=0;i<45;i++){
if ([self.view viewWithTag:i+100]){
CGRect frameOfGrass = [self.view viewWithTag:i+100].frame;
frameOfGrass.origin.y = -100;
[self.view viewWithTag:i+100].frame = frameOfGrass;
}}
}
completion:^(BOOL finished){
//
}];注意事项:y位置的每个imageView是随机数从600-700.
但是结果看起来更像UIViewAnimationOptionCurveEaseOut --“一条轻松的曲线会让动画快速开始,然后在它完成的时候变慢。”因为所有的图像都会慢下来。
下面是应用程序运行的截图:




知道为什么会这样吗?
发布于 2013-10-23 16:33:03
对于所有的草图像,旅行的距离并不是一样的。记住v=d/t,在你的例子中,所有的草图像都会以不同的速度传播,因为它们需要同时到达y.origin = -100。
试试这个:
frameOfGrass.origin.y = frameOfGrass.origin.y - 600;这将使所有的草图像在同一时间内保持相同的距离。
https://stackoverflow.com/questions/19546903
复制相似问题