Rotate along the z axis, such as a slot machine with kernel animations

I could move or animate my UIView with this code here:

- (void) makeAnim1{

    //downward animation 
    [UIView animateWithDuration:1.5
                          delay:0.15
                        options: UIViewAnimationCurveLinear
                     animations:^{
                         carousel.frame = CGRectOffset(carousel.frame, 0, 650);
                     }
                     completion:^(BOOL finished){ //task after an animation ends
                         [self performSelector:@selector(makeAnim1_1) withObject:nil afterDelay:2.0];
                         NSLog(@"Done!");
                     }];    
}

- (void) makeAnim1_1{

    //upward animation
    [UIView animateWithDuration:1.5
                          delay:0.1
                        options: UIViewAnimationCurveLinear
                     animations:^{
                         carousel.frame = CGRectOffset(carousel.frame, 0, -650);
                     } 
                     completion:^(BOOL finished){
                        NSLog(@"Done!");
                     }];    


} 

But he moves UIViewup and down. How can I make it spin like Slot machine, but only contains one image or view. Like rotation along the z axis. But make it contain more than one image.

Thanks for the help.

+5
source share
1 answer

frame transform. , () . z, , . transform CGAffineTransform, :

// rotate pi/2 degrees clockwise
carousel.transform = CGAffineTransformMakeRotation(M_PI_2);

, , , Core Animation views ( CATransform3D CGAffineTransform).

Core Animation, QuartzCore.framework QuartzCore/QuartzCore.h .

, , - UIView, , . CABasicAnimation, iOS, .

x :

CABasicAnimation *slotAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
[slotAnimation setToValue:[NSNumber numberWithFloat:M_PI_2]];
// animation customizations like duration and timing 
// that you can read about in the documentation 
[[carousel layer] addAnimation:slotAnimation forKey:@"mySlotAnimation"];

x, ( SO " Core Animation", ). , , , , .

+1

All Articles