Best way to implement animation on iPhone SDK?

只谈情不闲聊 提交于 2019-12-03 20:18:56

For your first question, I would think that CGAffineTransform would be the way to go. Using this, I would think something like this could work:

// 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)];   
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!