Reputation: 10159
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.
Upvotes: 2
Views: 739
Reputation: 860
create a CABasicAnimation for opacity; then add it to your CALayer
Upvotes: 0
Reputation: 291
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.
Upvotes: 0
Reputation: 12613
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.
Upvotes: 2