Reputation: 1475
I'm attempting to rotate my calayer object in my callback for a rotation gesture recognizer as such:
CGFloat angle = [(NSNumber *)[hitlayer valueForKeyPath:@"transform.rotation.z"] floatValue];
hitlayer.transform = CATransform3DMakeRotation( (angle+90) / 180.0 * M_PI, 0.0, 0.0, 1.0);
[hitlayer setValue:[NSNumber numberWithFloat:(angle+90)] forKey:@"transform.rotation.z"];
This works fine the first time. But subsequent times, the value returned by transform.rotation.z is still the original value (not the transformed value) so the layer doesn't rotate any further. Any ideas what i'm missing ?
thanks
Upvotes: 1
Views: 702
Reputation: 11274
The transform
property does not change the view's or layer's bounds or center. It just applies a transformation when it gets drawn, so it simply looks differently. So in your case, you have to keep track of the last degree value and add 90 on each call.
Upvotes: 2