0

I'm wondering if it's possible to "animate" a variable value. I'd essentially like to have a value change from x to y over a certain amount of time and cause a call to drawRect: on each iteration. The change in the variable value will affect how drawRect: processes.

I have thought of doing this manually, but I don't trust a number of things:

  • The accuracy of my custom UIViewAnimationCurveEaseInOut
  • The frequency of my iterations (if they're too frequent / hard on the GPU or too infrequent / laggy animations)
  • The transitions between sleeping and graphical processing using GCD

I've thought of using a KeyFrame animation, but I don't know how I would use the keys, properly.

Is there a way to do this using the built in animation schemes of iOS?

RileyE
  • 10,874
  • 13
  • 63
  • 106
  • 1
    Google "animatable property". It's very simple although the first can be hard. It's about moving from views to layers. – Sulthan Jun 13 '13 at 21:54
  • @Sulthan I'm trying that out now. Thank you! – RileyE Jun 13 '13 at 22:05
  • @Sulthan That's not working at all for me. I'm using a CALayer and I have a property called "percentage", but it is either not actually animating the property or not calling `+ (BOOL)needsDisplayForKey:(NSString *)key`, as it only ever calls the function with the key "percentage" once, which is after the animation ends. – RileyE Jun 13 '13 at 22:48

0 Answers0