莫斯科晚上给大家!我还是不熟悉iPhone动画的原理(顺便说一句,有没有人知道一个关于这个大而好的教程?),但在我的项目中,我想做的按钮“突出显示,不突出显示”闪烁通知用户它的标签已经改变。动画选择UIButton
此代码不会做任何事情(它只是闪烁的动画片段):
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.5];
[button setHighlighted: YES];
[UIView commitAnimations];
而这其中凸显的按钮,但不这样做的动画形式:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.5];
[button setSelected: YES];
[UIView commitAnimations];
任何人都可以帮助我说:
- 这段代码有什么问题?
- 什么可以解决这个问题?
-----------------------------------更新-------- ----------------------
我想那样的代码,但它无法正常工作或:
// ------------------------
// --- animation ----------
// ------------------------
- (void)animateIn
{
[UIView beginAnimations: @"animateIn" context:nil];
[UIView setAnimationDuration: 0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[control setBackgroundColor:[UIColor blackColor]];
[UIView commitAnimations];
}
- (void)animateOut
{
[UIView beginAnimations: @"animateOut" context:nil];
[UIView setAnimationDuration: 0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
[control setBackgroundColor:[UIColor whiteColor]];
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
if([animationID isEqualToString: @"animateIn"])
{
[self animateOut];
return;
}
else if ([animationID isEqualToString: @"animateOut"])
{
cycleCount++;
if(cycleCount < 3)
[self animateIn];
else
cycleCount = 0;
return;
}
}
@end
谢谢JustinXXVII,它似乎在工作。我已经像这样做了! – wh1t3cat1k 2010-11-11 05:48:03