开发者

Switching View within a ViewController

I am building an app that requires me to switch amongst 5 views and all of them开发者_JAVA百科 are in a single view controller class. I am able to switch them using addSubview and removeFromSuperview methods, but the problem is that I want to animate it with the current view moves out to left and the next view comes in from right.

I tried using this thread but was not able to get the desired result.

Any form of help will be highly appreciated.

Thanks in advance!!


You can use this

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

Hope this Helps....


you can use the following to animate views:

[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.
}

};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜