我有一个 gridView,我用来显示几个GridViewCell : UIView
. 向GidViewCell
自身添加一个 UILabel 并将一个附加UITapGestureRecognizer
到自身。
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[self addGestureRecognizer:gestureRecognizer];
[gestureRecognizer release];
在tapped:
我想播放一些动画,包括改变标签的背景颜色
- (void) tapped:(id)sender {
[UIView animateWithDuration:1.0
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
[(UILabel *)[[self subviews] objectAtIndex:0] setBackgroundColor:[UIColor blueColor]];
}
completion:^(BOOL finished){
[(UILabel *)[[self subviews] objectAtIndex:0] setBackgroundColor:[UIColor whiteColor]];
}
];
[self.delegate didSelectGridViewCell:self];
}
但标签只是眨眼间闪烁蓝色——如果有的话。如果我使用相同的代码但调整标签的 alpha 而不是背景颜色,一切都会按预期工作。
Apple 的文档将 backgroundColor 列为可动画的。是吗?难道我做错了什么?