Maintaining last stage when rotating through CATransform3DIdentity
Posted
by
Mikhail Naimy
on Stack Overflow
See other posts from Stack Overflow
or by Mikhail Naimy
Published on 2011-01-10T06:52:16Z
Indexed on
2011/01/10
7:53 UTC
Read the original article
Hit count: 238
Hi. i am rotating imageview through following code.it rotates fine..but when i rotate again , Imageview goes to previous angle( which is in initial stage) and then it rotates...any one can help in this?rotationTransform has been declared as CABasicAnimation* rotationAnimation in .h file....
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [touches anyObject];
startTouchPosition = [touch locationInView:self.view];
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [[event allTouches] anyObject];
location = [touch locationInView:self.view];
currentLocationRadians = atan2f(location.y - self.view.frame.size.height/2, location.x - self.view.frame.size.width/2);
lastLocationRadians = atan2f(startTouchPosition.y - self.view.frame.size.height/2, startTouchPosition.x - self.view.frame.size.width/2);
rotationTransform = CATransform3DIdentity;
rotationTransform = CATransform3DRotate(rotationTransform, currentLocationRadians-lastLocationRadians + rad, 0.0, 0.0, 1.0);
_imgview.layer.transform = rotationTransform;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
rotationTransform = _imgview.layer.transform;
}
© Stack Overflow or respective owner