I'm trying to use the +[UIView animateWithDuration:animations:]
method to animate a UITableViewCell
's background colour from white to red. However, the colour will not animate, it immediately jumps to red. I've switched out setBackgroundColor:
for setOpacity:
and that works fine. What could be causing the animation to fail using background colour? Below is the code I'm u开发者_运维知识库sing:
UITableView * tableView = (UITableView *)[self view];
[UIView animateWithDuration:0.2 animations:^{
[[tableView cellForRowAtIndexPath:
[NSIndexPath indexPathForRow:0 inSection:0]]
setBackgroundColor:[UIColor redColor]];
}];
You cannot animate changes to color properties. You will have to create two background views and fade between them using their .alpha
properties.
精彩评论