我正在为孩子们开发一个记忆游戏,我想知道如何用动画在两个UIImage之间切换?任何帮助..。
发布于 2010-08-02 16:08:40
您应该有一个视图(UIView),它将包含显示的图像视图,并在触摸时在它们之间进行切换(或者实现触摸事件,或者使用图像视图上方的按钮,或者使用按钮而不是图像视图)。
接下来是在一个容器视图中交换两个图像视图的示例代码(如上所述):
// setup the animation group
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)];
// swap the views and transition
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
[imageView1 removeFromSuperview];
[containerView addSubview:imageView2];
[UIView commitAnimations];您还可以查看Apple的Elements示例项目,其中包含一个工作示例……
https://stackoverflow.com/questions/3385778
复制相似问题