我知道如何通过移动/调整 UIView 的大小来实现基本动画。不过下面两个动画就显得有点复杂了。
1)想象一下汽车游戏,当您按下踏板按钮时,车速表就会旋转。如何制作那种条形“填满”圆形的动画?
2)第二个动画更容易描述。如何制作数字增加的动画,数字向下滑动,新数字从顶部出现,类似于老虎机。
对于你的第一个问题,我认为 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)];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)