我正在尝试使用+[UIView animateWithDuration:animations:]方法将UITableViewCell的背景色从白色动画化为红色。但是,该颜色不会有动画效果,它会立即跳转到红色。我已经将setBackgroundColor:切换为setOpacity:,但效果很好。使用背景色动画失败的原因是什么?下面是我使用的代码:
UITableView * tableView = (UITableView *)[self view];
[UIView animateWithDuration:0.2 animations:^{
[[tableView cellForRowAtIndexPath:
[NSIndexPath indexPathForRow:0 inSection:0]]
setBackgroundColor:[UIColor redColor]];
}];发布于 2011-07-05 19:13:02
您不能以动画形式更改颜色属性。您必须创建两个背景视图,并使用它们的.alpha属性在它们之间进行淡入淡出。
https://stackoverflow.com/questions/6581276
复制相似问题