2010-09-28 58 views
0

我知道CGAffineTransformMakeRotation可以旋轉圖像,CGAffineTransformMakeTranslation可以翻譯圖像。我也明白CGAffineTransformConcat可以合併兩個轉換。然而,我似乎無法找出一種方法來移動使用這兩個弧的圖像。我知道這是一個更爲數學的問題,但是有沒有人有他可以指向我的參考?使用CGAffine在圓弧上移動UIImageView

編輯:

[bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:] 

的伎倆。

參考:http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/clm/UIBezierPath/bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise

+0

您是否正在嘗試旋轉圖像以便沿着圓弧移動? – 2010-09-28 20:44:24

+0

是的,那正是我想要做的。 – 2010-09-28 20:45:20

回答

2

使用CAKeyframeAnimation並設置路徑而不是謹慎的值。

CAKeyframeAnimation *a = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 
CGRect circleRect = CGRectMake(0,0,50,50); 
a.duration = 2.0; 
a.rotationMode = kCAAnimationRotateAuto; 
a.path = [UIBezierPath bezierPathWithOvalInRect:circleRect].CGPath; 
[imageView.layer addAnimation:a forKey:@"moveCircle"]; 
1

旋轉它大約對應於圓弧的圓的中心。

這將涉及三個步驟:

1)轉換,使您的移動弧的起源中心。
2)旋轉適當的角度。
3)反轉從步驟1開始的翻譯。