【发布时间】:2012-01-14 14:03:44
【问题描述】:
我有一组 UIButtons 和 UILabels 我想在选择一个按钮并且它是正确的按钮时淡出。
我已经尝试了很多东西(在代码块中对它们进行了注释),只有 UILabel 淡出。我在这里错过了什么?
-(IBAction)answerButtonPressed:(UIButton *)sender {
NSLog(@"Game Question Answer Pressed: %i", sender.tag);
NSLog(@"%@", sender.titleLabel.text);
int selectedAnswer =0;
selectedAnswer = [question.answer intValue];
if (selectedAnswer == sender.tag) {
NSLog(@"GameQ %@ is the correct answer", sender.titleLabel.text);
//self.toggleView;
[labelA setAlpha:0];
[labelB setAlpha:0];
[labelC setAlpha:0];
[labelD setAlpha:0];
/*
[buttonA setAlpha:0];
[buttonB setAlpha:0];
[buttonC setAlpha:0];
[buttonD setAlpha:0];
[buttonA setHidden:YES];
[buttonB setHidden:YES];
[buttonC setHidden:YES];
[buttonD setHidden:YES];
*/
[sender setAlpha:1];
[sender setHidden:NO];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
[UIView animateWithDuration:2.0
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{buttonA.alpha = 0;}
completion:nil];
[UIView setAnimationDelegate:[UIApplication sharedApplication]];
[UIView setAnimationDidStopSelector:@selector(endIgnoringInteractionEvents)];
[UIView commitAnimations];
我已经清理了这个方法并且只使用了一种类型的动画块。 UIButton 仍然不会淡出,但标签会淡出。这是我的动画块:
[UIView animateWithDuration:2.0
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{buttonA.alpha = 0;}
completion:nil];
[UIView animateWithDuration:2.0
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{labelA.alpha = 0;}
completion:nil];
【问题讨论】:
标签: iphone ios ipad uibutton core-animation