我试图做一个卡片翻转动画...但没有任何反应。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
要解决这个问题,您可能必须使用关键帧动画或多个动画。请记住,当卡片翻转一半时,你想改变一些东西。 –