views:

40

answers:

1

Hello,

I have a UITableViewCell drawn using drawRect:. I'm drawing an shape in drawRect and would like to animate this shape (using some parameter) when using the cell goes into edit mode.

However, I couldn't find how to use animated parameters within drawRect. Could someone point me to the right documentation or is it impossible?

Thanks!

A: 

Look into using CAShapeLayer for making shapes, it has an animatable property path.

CAShapeLayer* shape = [CAShapeLayer layer];
// Changing this will implicitly animate to new path
shape.path = [UIBezierPath bezierPathWithOvalInRect:someRect].CGPath;
shape.fillColor = [UIColor redColor].CGColor;

For more control over the animation, use CATransaction.

aegzorz
True, but you could also use CoreAnimation [layer presentationLayer] to get current properties of layer being drawn :]
Krzysztof Zabłocki