在ViewController中切换视图

时间:2011-03-22 09:24:14

标签: iphone animation uiview

我正在构建一个应用程序,要求我在5个视图之间切换,所有这些视图都在一个视图控制器类中。我可以使用addSubviewremoveFromSuperview方法切换它们,但问题是我想要使用当前视图向左移动并从右边进入下一个视图来设置动画。

我尝试使用this thread但未能获得所需的结果。

任何形式的帮助都将受到高度赞赏。

提前致谢!!

2 个答案:

答案 0 :(得分:0)

您可以使用以下内容为视图制作动画:

[UIView animateWithDuration:0.8f animations: 
^{
  // and of course you can edit the duration according to your need 
  // Change Alpha value of the view or set it to hidden    
  // you can also change the frame; which will make the view change it position with animation to the new provided frame. 
}
completion: ^(BOOL finished)
{
 // Your Code here; if you want to add other animation on the end of the proccess.
}

};

答案 1 :(得分:0)

您可以使用此

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.5];
    CGAffineTransform transform = CGAffineTransformMakeTranslation(xOffSet, yoffSet);
    myView.transform = transform;
    [UIView commitAnimations];

希望这有助于......

相关问题