2011-04-15 75 views
0

我有一个图像旋转,我想要的是第二个图像卡在它上面,它像第一个旋转。请,我该怎么做?iphone图像移动像另一个图像

+0

您可以在旋转之前将图像添加到背景图像上(即,通过重叠像素使图像在两个图像之外)。如果这是可能的,你不需要担心独立旋转两个。 – Scott 2011-04-15 15:51:11

回答

1

我不在我的电脑,所以我不能测试这个,但我认为它应该得到你想要的。

// assuming you already have your views 
// viewOne, viewTwo 

[viewOne addSubview:viewTwo]; // add viewTwo to viewOne 

// let's assume that you call this code here one time per second 
[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:1.0]; 
[UIView setAnimationCurve:UIViewAnimationCurveLinear]; 

// when this is 1.0, the image will rotate 360 
// ... when it is .5, it should rotate 180, etc... 
float rotationFactor = 0.1f; 

// viewTwo's rotationFactor will be added to view 1's in the transform below 
float rotationFactor2 = 0.1f; 

viewOne.transform = CGAffineTransformMakeRotation(M_PI_2 * rotationFactor); 
viewTwo.transform = CGAffineTransformMakeRotation(M_PI_2 * (rotationFactor + rotationFactor2); 

[UIView commitAnimations];