代码之家  ›  专栏  ›  技术社区  ›  Jazzmanouch

Iphone Flip图像

  •  0
  • Jazzmanouch  · 技术社区  · 14 年前

    我要为孩子们开发一个记忆游戏,我想知道如何用动画在两个UIImage之间切换?

    1 回复  |  直到 14 年前
        1
  •  0
  •   Michael Kessler    14 年前

    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];