UILabel的backgroundColor是不是animation?
我有一个gridView,我用来显示几个GridViewCell : UIView
。 GidViewCell
将UILabel添加到自身,并将UITapGestureRecognizer
到自身。
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)]; [self addGestureRecognizer:gestureRecognizer]; [gestureRecognizer release];
在tapped:
我想玩一些animation,包括改变标签的背景颜色
- (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而不是背景颜色,一切都按预期工作。
苹果的文档列出backgroundColor作为animation。 是吗? 难道我做错了什么?
我从来没有尝试过这个,但我知道有谁有。 我不知道这是否是在文档或代码中的错误。 我假设后者,因为UILabel
从UIView
inheritance,我知道你可以animationUIView
的背景。 解决方法显然是深入底层的CALayer
并在那里设置背景颜色。