我知道如何通过移动/调整UIView来实现基本动画。但是,以下两个动画似乎有点复杂。
1)想象一下汽车游戏,当你按下踏板按钮时,速度表旋转。如何将条形“填满”圆形的动画?
2)第二个动画更容易描述。如何在数字向下滑动的情况下增加数字动画,新数字从顶部出现,类似于老虎机。
答案 0 :(得分:6)
对于你的第一个问题,我认为CGAffineTransform将是最佳选择。使用这个,我认为这样的事情可以起作用:
// BarView is a derived class from UIView that knows how to draw a "bar"
BarView view[NumBars];
for(int i = 0; i < NumBars; i++)
{
// First place the view at the center of the instrument
[view[i] setCenter:CGPointMake(InstrumentX, InstrumentY)];
// Now translate the view InstrumentWidth units on the positive X-Axis
CGAffineTransform translate = CGAffineTransformMakeTranslation(InstrumentWidth, 0);
// Rotate the view about the origin by an angle related to which "bar" this is
CGAffineTransform rotate = CGAffineTransformMakeRotation(i*AngleBetweenBars);
// create a transform matrix from the translation and rotation matrices and apply it to the view
[view[i] setTransform:CGAffineTransformConcat(translate, rotate)];
}