0
我有3張卡片。首先所有卡片向右移動,然後在1秒後卡片2出現在視圖的左側,然後再多出一秒卡片2移動到右邊。我使用下面的代碼實現了它。當視圖加載我有下面的代碼,一個接一個地以3個步驟進行動畫製作ios
counter = 0;
timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(performAnimationToRight) userInfo:nil repeats:YES];
這裏是performAnimationToRightMethod
-(void)performAnimationToRight
{
if (counter == 0) {
CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(388,0);
[UIView beginAnimations:@"Move1" context:nil];
[UIView setAnimationDuration:2];
card0.transform = transformToLeft;
card1.transform = transformToLeft;
card2.transform = transformToLeft;
[UIView commitAnimations];
}else if(counter == 50){
card2.frame = CGRectMake(-300,card2.frame.origin.y, card2.frame.size.width, card2.frame.size.height);
}else if(counter == 200){
timer = nil;
counter = 0;
CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(-300,0);
[UIView beginAnimations:@"Move2" context:nil];
[UIView setAnimationDuration:2];
card2.transform = transformToLeft;
[UIView commitAnimations];
}
counter++;
}
問題的實現是在最後一個動作卡2而不是移動向右移動到左邊,這是羯羊或我無法使用,
CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(-300,0);
或
CGAffineTransform transformToLeft = CGAffineTransformMakeTranslation(+300,0);
點