0

CAShapeLayerを使用してサークルを作成しました。この円を固定中心で回転させたい。アニメーションには次のコードを使用しています。このコードサークルの使用は回転していますが、フィックスセンターではありません。センターは変化し続けていますか。私はそれが起こらないようにしたい。

これは私のアニメーションのコードです

CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * rotations * 2.0 ];
    rotationAnimation.duration = 10.0; //    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 1.0; 
    rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

    [circle1 addAnimation:rotationAnimation forKey:@"rotationAnimation"];

ありがとう

4

1 に答える 1

0

これにより、長方形の内側に保持されます。

[circle1 setAnchorPoint:(0.5,0.5)]; 

CGFloat angle = rotationAnimation.toValue;
CGFloat radius = someRadius;
CGPoint rotationCenter = CGPointMake(centerX,centerY); 
circle1.frame = CGRectMake(rotationCenter.x + radius * cos(angle),  rotationCenter.y + radius * sin(angle), circle1.frame.size.width, circle1.frame.size.height);
于 2013-03-05T11:18:39.400 に答える