Timbo
Timbo

Reputation: 1214

Animating changing values of CGContextFillRect

Is it possible to smoothly animate a changed width property of CGContextFillRect over say 5 seconds?

CGContextFillRect(context, CGRectMake(x, y, width, height));

I'm trying to write a method for an iphone app that basically takes a time value and animates the change of CGContextFillRect width from the initial value to the final value smoothly. I need steering in the right direction of research.

If not CGContextFillRect then perhaps there is some other rectangle could be animated like a CALayer? hmmm

Upvotes: 0

Views: 1160

Answers (1)

Joshua Weinberg
Joshua Weinberg

Reputation: 28688

A CALayer can be animated trivially in this way. If you want a smooth animation of the CGFillRect you'd have to use a timer or a CADisplayLink or some other timed system.

To do this with a CALayer look into CABasicAnimation, you can tell it to do a cumulative animation, repeated however many times you want.

Upvotes: 1

Related Questions