3
我想轉換一些使用beginAnimations的動畫代碼來使用動畫塊。那我遇到的問題是,當我使用動畫塊中的動畫去得更快,我似乎無法改變持續時間值開始動畫和使用動畫塊的動畫速度不同
這個調整的速度是我開始的最初:
birdFly.image = [UIImage imageNamed: @"bird1.png"];
[self.view addSubview:birdFly];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:20];
birdFly.frame = CGRectMake(-1116,27,111,48);
[UIView commitAnimations];
[birdFly release];
這是我第一次嘗試取代我上面的東西。使用此代碼,動畫比使用原始代碼的速度快得多。即使在更改時間似乎並沒有在所有的改變速度:
birdFly.image = [UIImage imageNamed: @"bird1.png"];
[self.view addSubview:birdFly];
[UIView animateWithDuration:20
animations:^{
birdFly.frame = CGRectMake(-1116,27,111,48);
}];
我也試過這個,以爲我需要完成塊,但速度還是一樣快,相比我原本當我沒不使用塊。
birdFly.image = [UIImage imageNamed: @"bird1.png"];
[self.view addSubview:birdFly];
UIViewAnimationOptions options = UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction;
[UIView animateWithDuration:20 delay:0.0 options:options animations:^
{
birdFly.frame = CGRectMake(-1116,27,111,48);
} completion:nil];
代碼是否都在做同樣的事情?我在這裏錯過了很簡單的東西嗎?我認爲增加持續時間會讓鳥慢下來,減少它會使它快一些,但是當用塊來改變它時似乎沒有任何影響。
任何指導,將不勝感激。
感謝。
亞倫
謝謝。這工作。我認爲我沒有嵌套它,但是在你提到這個之後,我做了一些觀察,實際上它嵌套在另一個動畫塊中。感謝! – AaronG 2010-11-20 00:04:11