I see a lot of code that rotates a view as follows:
CABasicAnimation *centerToRightRotate
= [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
centerToRightRotate.fromValue = @(0);
centerToRightRotate.toValue = @(M_PI/8);
centerToRightRotate.duration = 0.15;
[self.view.layer addAnimation:centerToRightRotate forKey:nil];
(for example, many of the answers to this question)
However, when I try to access self.view.layer.transform.rotation
or self.view.layer.transform.rotation.z
, the compiler will tell me "No member named 'rotation' in CATransform3D". The docs for CATransform3D
also does not show rotation
as an instance property.
My guess is CAAnimation
is somehow translating the transform.rotation
key path into the appropriate transformation, but I want to know what is actually going on under the hood. What exactly is going on here?