Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)spinLayer:(CALayer *)inLayer duration:(CFTimeInterval)inDuration
- direction:(int)direction newFrame:(CGPoint)newFrame
- {
- CABasicAnimation* rotationZ, *theAnimationX, *theAnimationY;
- // Rotate about the z axis
- rotationZ = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
- rotationZ.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * direction / 2.5];
- theAnimationX=[CABasicAnimation animationWithKeyPath:@"position.x"];
- theAnimationX.toValue=[NSNumber numberWithFloat:(newFrame.x-object.center.x)];
- theAnimationY=[CABasicAnimation animationWithKeyPath:@"position.y"];
- theAnimationY.toValue=[NSNumber numberWithFloat:(newFrame.y-object.center.y)]; //newFrame.origin.y];
- CAAnimationGroup *theGroup = [CAAnimationGroup animation];
- theGroup.fillMode = kCAFillModeForwards;
- theGroup.removedOnCompletion = NO;
- theGroup.delegate = self;
- theGroup.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
- theGroup.duration = inDuration;
- theGroup.repeatCount = 0;
- theGroup.animations = [NSArray arrayWithObjects:rotationZ, theAnimationX, theAnimationY, nil]; // you can add more
- [inLayer addAnimation:theGroup forKey:@"animateLayer"];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement