View difference between Paste ID: cR8zrKRq and P0ypj7RY
SHOW: | | - or go back to the newest paste.
1
- (void)spinLayer:(CALayer *)inLayer duration:(CFTimeInterval)inDuration
2
        direction:(int)direction newFrame:(CGPoint)newFrame
3
{
4
    
5
    CABasicAnimation* rotationZ, *theAnimationX, *theAnimationY;
6
    
7
    
8
    
9
    // Rotate about the z axis
10
    rotationZ = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
11
    rotationZ.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * direction / 2.5];
12
    
13-
    theAnimationX=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
13+
    theAnimationX=[CABasicAnimation animationWithKeyPath:@"position.x"];
14
    theAnimationX.toValue=[NSNumber numberWithFloat:(newFrame.x-object.center.x)];
15-
    theAnimationY=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
15+
    theAnimationY=[CABasicAnimation animationWithKeyPath:@"position.y"];
16
    theAnimationY.toValue=[NSNumber numberWithFloat:(newFrame.y-object.center.y)]; //newFrame.origin.y];
17
    
18
    
19
    CAAnimationGroup *theGroup = [CAAnimationGroup animation];
20
    theGroup.fillMode = kCAFillModeForwards;
21
    theGroup.removedOnCompletion = NO;
22
    theGroup.delegate = self;
23
    theGroup.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
24
    
25
    theGroup.duration = inDuration;
26
    theGroup.repeatCount = 0;
27
    theGroup.animations = [NSArray arrayWithObjects:rotationZ, theAnimationX, theAnimationY, nil]; // you can add more
28
    
29
    
30
    
31
    [inLayer addAnimation:theGroup forKey:@"animateLayer"];
32
    
33
    
34
    
35
}