Domanda

I have a UIView and I want to get it's current frame while it's animated. I am using a basic animation:

[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:3];
_testView.frame = CGRectMake(0, 100, 40, 40);
[UIView commitAnimations];

and I have a button which should add another UIView at the current position of the first one while animated, but when I press the button, it adds it to the end position of the animation... Any suggestions? Thank you in advance!

È stato utile?

Soluzione

Most probably you're setting the newly added UIView properties based on the animated view's modelLayer. Let's try to setup the UIView properties based on the animated view's presentationLayer:

The layer object returned by this method provides a close approximation of the layer that is currently being displayed onscreen. While an animation is in progress, you can retrieve this object and use it to get the current values for those animations.

CALayer Class Reference

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top