【发布时间】:2010-03-11 22:22:20
【问题描述】:
我正在寻找一种在 iPhone 应用程序中创建菜单的方法,该菜单允许按钮围绕中心点旋转。直观地说:按钮是行星,中心是太阳。
- 这将允许用户围绕圆形路径“旋转”按钮。
** 一个实际的例子是他们的 iPhone 应用程序的 Poynt 菜单。 **
我开始使用这段代码,这是我从 mahboudz 的帖子中找到的:
- (void) runSpinAnimationWithDuration:(UIView*)animatedView withDuration:(CGFloat) duration;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * 1 * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1.0;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[animatedView.layer setAnchorPoint:CGPointMake( 0.5, 0.5 )];
[animatedView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
这里有一篇关于轮换的有趣帖子:link text
无论如何,我可以旋转按钮 - 但不能围绕预定路径(如行星场景)。
任何帮助将不胜感激。
【问题讨论】:
标签: iphone animation rotation cabasicanimation