Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

flummoxed

macrumors member
Original poster
Nov 27, 2010
38
0
I am trying to perform an animation on a UIView and evaluate its current position at various times during the animation.

I can perform the animation ok, but I cannot get any discreet data on the center position. I have discovered that when the animation block is initiated the center position is immediately assigned the end position in the animation block command. Here is the iOS 4.0 block code:

[UIView animateWithDuration: 3.0 delay: 0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
mainView.center = CGPointMake(160.0, -1800.0); }
completion:NULL];

As I mentioned, the code runs ok, but any time during the view animation the center point always reads as -1800 even though the view itself has not yet reached that position.

Is there a way to evaluate the view's real position at various times during it's animation?
 

flummoxed

macrumors member
Original poster
Nov 27, 2010
38
0
I've made some progress in determining why this does not work as I expect.

It has to do with Core Animation layers and how animations are implemented and displayed.

Apparently there are 3 layers that a view is built upon: the front end interactive layer that we normally create and work with;
a presentation layer that reflects the view's current state;
and the render layer that the Quartz compositing engine uses to display the final result.

In my case I am interested in accessing the presentation layer.
It is a fact that when you commit an animation to an view that the view properties being animated immediately change to the destination values.
That is just how CA works.
The presentation layer works differently in that it's property values change continuously to reflect the actual state at any given time.

I haven't figured out the exact code to get this data, but I'm sure it is explained somewhere in the CA docs.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.