views:

32

answers:

1

hi guys,

i have a UISLider that is being animated - going across the screen over a 91.0 second period. i would like to be able to stop the animation spot on.

the code:

 [UIView animateWithDuration:91.0
        delay:0.0
        options:UIViewAnimationOptionRepeat|
                    UIViewAnimationOptionAllowUserInteraction|
            UIViewAnimationOptionBeginFromCurrentState
        animations:^{[UIView setAnimationDuration:91.0];
                 [myUISlider setValue:91.0];}
            completion:nil];

    [UIView commitAnimations];
  • one way to stop an animation is setting a new value. however, i cannot READ the current value/position of the slider DURING the animation. when accessing mySlider.value i get the target value (where the animation will end, i.e 91.

i did some digging up and came across the continuous flag which fires up an action method and is setup up to YES by default. from the developer reference:

"...if YES, the slider sends update events continuously to the associated target’s action method...".

however, the value here is, again, 91.0...

thank you for your time.

yours,

~nir.

A: 

If you ask the UISlider's layer for its -presentationLayer, you can then interrogate that copy of the layer for the near real-time animated properties. From the CALayer documentation:

Returns a copy of the layer containing all properties as they were at the start of the current transaction, with any active animations applied.

tjw
thanx for your answer tjw. following up on your suggestion i found that this class provides information about the layer itself. for example, i was able to extract the position.x and position.y of the slider but not the current value of the slider point itself. thoughts?
pengas
Oops, I seem to have misunderstood your question. Perhaps you can amend your question to show how you are controlling the animation speed of the value. You are presumably calling -setValue:animated:, but that ignores the duration set in any enclosing UIView animation block.
tjw
thanks TJW, i just re-edited the post and added some code. i hope it will be clearer now what i am trying to achieve. thanks for your time.
pengas