莫斯科晚上給大家!我還是不熟悉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