我試圖做一個卡片翻轉動畫...但沒有任何反應。iPhone試圖使用塊動畫來模擬卡片翻轉,但沒有任何反應,沒有動畫
這就是我所做的 1.創建一個容器視圖,以保存兩個視圖的動畫。 2.創建第一個視圖。 3.將其添加到容器。 4.創建第二視圖 3.啓動動畫塊,beginAnimations 4.呼叫setAnimationTransition放入視圖容器 5.添加所述第二視圖的視圖容器 6.提交動畫,
我的代碼
// create container view
CGRect viewRect = CGRectMake(10, 10, 100, 100);
UIView* myView = [[UIView alloc] initWithFrame:viewRect];
// create 2 viues to flip between for animation
UIImage *i= [ UIImage imageNamed : @"card1.jpg"];
UIImageView *topCard=[ [UIImageView alloc] initWithImage: i ];
topCard.frame= CGRectMake(0,0,100,100);
[myView addSubview:topCard];
[self.view addSubview:myView];
i= [ UIImage imageNamed : @"card2.jpg"];
UIImageView *butCard=[ [UIImageView alloc] initWithImage: i ];
butCard.frame= CGRectMake(0,0,100,100);
// set up the animation
[UIView beginAnimations:@"Flip Top Card" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:0];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut ];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:myView cache:YES];
[myView addSubview:butCard];
// start the animation
[UIView commitAnimations];
-Ted
要解決這個問題,您可能必須使用關鍵幀動畫或多個動畫。請記住,當卡片翻轉一半時,你想改變一些東西。 –