Reputation: 1047
According to this answer there's a way to make a CGAffineTransform permanent:
iphone - making the CGAffineTransform permanent
but it's not explained... the answer tells about a copy that is generated by the animation but isn't clear how to get it and assign to the original object, so this is the code, how to make it permanent?
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
float angleRadians = 180 * ((float)M_PI / 180.0f);
CGAffineTransform t = CGAffineTransformMakeRotation(angleRadians);
self.myView.transform = t;
[self.myView setCenter:CGPointMake(160, 220)];
[UIView commitAnimations];
Thanks
Upvotes: 1
Views: 3040
Reputation: 604
In iOS 4.0 or greater Apple recommends using Block based animations
reference: What are block-based animation methods in iPhone OS 4.0?
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^{ self.myView.transform = CGAffineTransformMakeRotation(M_PI) }
completion:NULL];
Not sure if this will solve your problem exactly, but it is a step in the right direction.
Upvotes: 0
Reputation: 10333
You can try going a level down to Core Animation and apply transform animation with following properties:
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.fromValue = [NSValue valueWithCATransform3D: t];
animation.toValue = [NSValue valueWithCATransform3D: t];
animation.duration = 0.0;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
[yourView.layer addAnimation:animation forKey:@"transform"];
Then you can do other core animations and it should retain the transform. Don't forget to import QuartzCore framework.
Upvotes: 1