开发者

How to rotate UIImageView in 3d circular way?

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 i开发者_JS百科s an image for more explanation

How to rotate UIImageView in 3d circular way?

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];


Your question does not match what the image shows. Z is going through the display with negative values being closer to you.

you have 2 kinds of transforms available: - 2D on the level of UIKit view.transform - (pseudo-)3D on CALayers view.layer.transform

a rotation transform around Z is done with CATransform3DRotate

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜