问题
I want to get an effect of a UIView doing 360 degree rotation around the Y axis without stopping.
回答1:
Put the following code in your view controller:
CATransform3D t3d = CATransform3DIdentity;
// m34 sets the amount of perspective
t3d.m34 = 1.0/-1000.0;
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
self.view.layer.transform = CATransform3DRotate(t3d, M_PI, 0, 1, 0);
}
completion:^(BOOL finished) {
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
self.view.layer.transform = CATransform3DRotate(t3d, 2*M_PI, 0, 1, 0);
}
completion:^(BOOL finished) {
self.view.layer.transform = CATransform3DIdentity;
}];
}];
It's pretty messy, if anybody has any suggestions on how to clear this up, let me know ;)
来源:https://stackoverflow.com/questions/8041662/how-to-do-uiview-nonstop-flip-animation