首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在iPhone SDK上实现动画的最佳方法?

问在iPhone SDK上实现动画的最佳方法?
EN

Stack Overflow用户
提问于 2009-06-09 15:52:24
回答 1查看 5.1K关注 0票数 3

我知道如何通过移动/调整UIView来实现基本的动画。然而,下面两个动画似乎有点复杂。

1)想象一个汽车游戏,当你按下踏板按钮时,速度表旋转。如何制作那种条形“填充”成圆形的动画?

2)第二个动画更容易描述。如何做动画的数字增加,在那里的数字滑落和新的数字出现在顶部类似于老虎机。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-06-09 16:16:25

对于你的第一个问题,我认为CGAffineTransform是最好的选择。用这个,我想像这样的东西可以起作用:

代码语言:javascript
复制
// 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)];   
}
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/970939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档