How to spinning the CALayer on current location?
thanks in advance
How to spinning the CALayer on current location?
thanks in advance
- (CAAnimation*)animationForSpinning {
// Create a transform to rotate in the z-axis
float radians = DegreesToRadians( 360 );
CATransform3D transform;
transform = CATransform3DMakeRotation(radians, 0, 0, 1.0);
// Create a basic animation to animate the layer's transform
CABasicAnimation* animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform"];
// Now assign the transform as the animation's value. While
// animating, CABasicAnimation will vary the transform
// attribute of its target, which for this transform will spin
// the target like a wheel on its z-axis.
animation.toValue = [NSValue valueWithCATransform3D:transform];
animation.duration = 2; // two seconds
animation.cumulative = YES;
animation.repeatCount = 10000; "forever"
return animation;
}
- (void)spinLayer:(CALayer*)layer {
// Create a new spinning animation
CAAnimation* spinningAnimation = [self animationForSpinning];
// Assign this animation to the provided layer's opacity attribute.
// Any subsequent change to the layer's opacity will
// trigger the animation.
[layer addAnimation:spinningAnimation forKey:@"opacity"];
// So let's trigger it now
layer.opacity = 0.99;
}
I used Above code for animation.....
But i want my CALayer rotate self. what to do?
any one help me out.