Re: [問題] Interface Builder 動畫問題???
※ 引述《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
12/28 23:37, 3F
→
12/28 23:40, , 4F
12/28 23:40, 4F
推
12/28 23:42, , 5F
12/28 23:42, 5F
推
12/29 18:02, , 6F
12/29 18:02, 6F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 5 之 5 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章