Re: [問題] Interface Builder 動畫問題???

看板MacDev作者 (zonble)時間15年前 (2009/12/28 23:20), 編輯推噓3(303)
留言6則, 3人參與, 最新討論串5/5 (看更多)
※ 引述《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

12/28 23:31, , 1F
謝謝~ :)
12/28 23:31, 1F

12/28 23:32, , 2F
想再問一下 就是我該如何自己設定動畫的時間長度??? @ @"
12/28 23:32, 2F

12/28 23:37, , 3F
+ (void)setAnimationDuration:(NSTimeInterval)duration
12/28 23:37, 3F

12/28 23:40, , 4F
同樣在 UIView reference 裡頭
12/28 23:40, 4F

12/28 23:42, , 5F
OK 謝謝你~ 我再自己研究看看
12/28 23:42, 5F

12/29 18:02, , 6F
用caanimation的timingFucntions也可以
12/29 18:02, 6F
文章代碼(AID): #1BECp6Xb (MacDev)
文章代碼(AID): #1BECp6Xb (MacDev)