Search code examples
iphoneobjective-canimationtween

Tween a value in iPhone objective-C


Is it possible to tween a variable (let's say a float from 0.0 to 2.0 over a period of time) in objective-C? Something like what TweenMax would do in flash. I guess the class methods of UIView don't do that. Is it doable maybe with CoreAnimation? Or would someone have to use NSTimer?

Thanks


Solution

  • Use an NSTimer on a selector that increments a member variable from its start value of 0.0 by the increment value.

    When the variable reaches the end point (2.0), invalidate the NSTimer instance to finish incrementing.

    See the documentation for more information about the method to use.