Vik*_*ica 3 cocoa-touch objective-c uianimation ios
我有一个gridView,我用来显示几个GridViewCell : UIView.在GidViewCell增加了一个的UILabel本身并附加一个UITapGestureRecognizer自己.
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[self addGestureRecognizer:gestureRecognizer];
[gestureRecognizer release];
Run Code Online (Sandbox Code Playgroud)
在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];
}
Run Code Online (Sandbox Code Playgroud)
但是标签只是闪烁蓝色一眨眼 - 如果有的话.如果我使用相同的代码,但调整标签的alpha而不是背景颜色,一切都按预期工作.
Apple的文档将backgroundColor列为动画.是吗?难道我做错了什么?
csa*_*ano 11
我自己从未尝试过,但我知道有人.我不知道这是文档或代码中的错误.我假设后者自从UILabel继承UIView而且我肯定你能够为a的背景设置动画UIView.解决方法显然是深入到底层CALayer并在那里设置背景颜色.
| 归档时间: |
|
| 查看次数: |
3310 次 |
| 最近记录: |