看板 MacDev 關於我們 聯絡資訊
※ 引述《haman (...)》之銘言: : ※ 引述《offname (Loafer是了好)》之銘言: : 不好意思我又來問問題了... : 如果我想要讓這些按鈕在移動上有時間差的話 : 應該加上哪些東西??? : 比如說"B"移動了一下以後 : 才換"A"移動 : 還有該如何自己決定它們的移動時間??? : 謝謝 有幾種方法 1. 如果是想要自己用時間安排順序 - (void)myCall { // 馬上執行 [self method1]; // 2 秒鐘之後執行 [self performSelector:@selector(method2) withObject:nil afterDelay:2.0]; } - (void)method1 { CGRect newButtonAFrame = CGRectMake(...); [UIView beginAnimations:nil context:NULL]; buttonA.frame = newButtonAFrame; [UIView commitAnimations]; } - (void)method2 { CGRect newButtonBFrame = CGRectMake(...); [UIView beginAnimations:nil context:NULL]; buttonB.frame = newButtonBFrame; [UIView commitAnimations]; } 2. 如果是想要一個動畫做完,再做另外一個 - (void)myCall { [self method1]; } - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { if ([animationID isEqualToString:@"animation1"] && [finished boolValue]) { [self method2]; } } - (void)method1 { CGRect newButtonAFrame = CGRectMake(...); [UIView beginAnimations:@"animation1" context:NULL]; // 在動畫結束的時候,我們要呼叫上面那個 // animationDidStop:finished:context [UIView setAnimationDidStopSelector:(animationDidStop:finished:context)]; buttonA.frame = newButtonAFrame; [UIView commitAnimations]; } - (void)method2 { CGRect newButtonBFrame = CGRectMake(...); [UIView beginAnimations:@"animation2" context:NULL]; buttonB.frame = newButtonBFrame; [UIView commitAnimations]; } 在 UIView reference 裡頭都有說 http://ppt.cc/HQ7a -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.42.199.13
haman:謝謝~ :) 12/28 23:31
haman:想再問一下 就是我該如何自己設定動畫的時間長度??? @ @" 12/28 23:32
zonble:+ (void)setAnimationDuration:(NSTimeInterval)duration 12/28 23:37
zonble:同樣在 UIView reference 裡頭 12/28 23:40
haman:OK 謝謝你~ 我再自己研究看看 12/28 23:42
offname:用caanimation的timingFucntions也可以 12/29 18:02