Tween value in iPhone objective-C

Is it possible to tweak a variable (say float from 0.0 to 2.0 over a period of time) in objective-C? Something like what TweenMax would do in flash. I think the methods of the UIView class don't do this. Is this possible with CoreAnimation? Or should someone be using NSTimer?

thank

+2


source to share


3 answers


Use a selector NSTimer

that increments the value of the member variable from an initial value of 0.0 by the increment value.

When the variable reaches the endpoint (2.0), the invalidate

instance NSTimer

to end increment.



For more information on the method used, see the documentation .

+2


source


What do you do? If you are trying to spice things up, you can use a CA and it will handle calculating intermediate values ​​over time.



If you are trying to do something not related to views or animations, you will need to do it yourself (using a timer or a custom property implementation that dynamically calculates the value based on the current time when it is accessed).

+2


source


Lately I've been working on merging something from a framework of which the "tweener" is part.

I'm still pretty new to obj c, but so far it seems to serve my purposes well. Feel free to drop in / play!

ShinobiTweener v0.1 for Objective-C

+1


source







All Articles