我有一个旋转的图像,我想要的是第二个图像被粘在它上面,它就像第一个一样旋转。请问,我该怎么做?
答案 0 :(得分: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];