2
votes

I have a subclass of UIView that draws a number with a border around it using Core Graphics (unread count style). I have this in a UITableViewCell and change the color of the border when setSelected:animated: is called. The problem is that it does not animate the change.

Is there any way on the iPhone to animate the change of Core Graphics drawing. All I want is a simple fade from one state to the other.

3

3 Answers

2
votes

Your best bet might be to add a UIImageView to your UIView subclass. Then you can animate the change of the image like so:

[UIView beginAnimations:nil context:NULL];
[imageView setImage:newImage];
[UIView commitAnimations];

Just hold two images for the different color borders and update them to fit when the numbers change. Should only require a bit of rearranging the drawing code.

0
votes

Try placing another view with the different color border on top, alpha set to 0. Then you fade in the new border and fade out the old border using a UIView animation block. The effect will be a cross fade between the two border colors.

0
votes

create a CABasicAnimation for opacity; then add it to your CALayer