开发者

iPhone animate Core Graphics

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 c开发者_C百科hange of Core Graphics drawing. All I want is a simple fade from one state to the other.


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜