Hello, I m new to core animation i want to rotate an imageview left or right but i want it to be rotated in z axis so it can looks like a circular rotation.Here is an image for more explanation
i want to rotate the image the inner imageview these are two imageview's.
i have tried this code please someone apply this and correct the code.
-(void)Rotate
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:3.0];
CATransform3D t1 = CATransform3DIdentity;
if(goingCW)
{
t1 = CATransform3DRotate(t1, radians(90), 0, 1, 0);
t1 = CATransform3DTranslate(t1, CUBESIZE/2, 0, 0);
t1 = CATransform3DRotate(t1, radians(90), 0, 1, 0);
t1 = CATransform3DTranslate(t1, CUBESIZE/2, 0, 0);
t1 = CATransform3DRotate(t1, radians(90), 0, 1, 0);
t1 = CATransform3DTranslate(t1, CUBESIZE/2, 0, 0);
CATransform3D moveTransform = CATransform3DRotate(t1, 0.0, -1.0, 0.0, 0.0);
[InnerView.layer setTransform:moveTransform];
NSLog(@"Going Left");
}
else
{
NSLog(@"Going Right");
t1 = CATransform3DRotate(t1, radians(90), 0, 1, 0);
t1 = CATransform3DTranslate(t1, CUBESIZE, 0, 0);
CATransform3D moveTransform = CATransform3DRotate(t1, 0.0, 1.0, 0.0, 0.0);
[InnerView.layer setTransform:moveTransform];
}
goingCW=!goingCW;
[UIView commitAnimations];
}
call this with a timer in viewDidLoad or in applicationDidFinishLaunching
goingCW = YES; // change this to NO to make it start rotating CCW instead A bool flag in header file.
NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(Rotate) userInfo:nil repeats:YES];