如下,一个UIContainerView内切换两个Controller,当点击登录的时候UIContainerView的视图为LoginController,当点击登记的时候UIContainerView中的视图为RegisterController
在主视图内先做两个按钮的事件。这个不用说啦。当触发按钮事件的时候调用以下代码就可以。
var newController = self.storyboard?.instantiateViewControllerWithIdentifier("RegisterController") as! RegisterController let oldController = childViewControllers.last as! UIViewController oldController.willMoveToParentViewController(nil) addChildViewController(newController) newController.view.frame = oldController.view.frame //isAnimating = true transitionFromViewController(oldController, toViewController: newController, duration: 0.1, options: UIViewAnimationOptions.TransitionNone, animations: nil, completion: { (finished) -> Void in oldController.removeFromParentViewController() newController.didMoveToParentViewController(self) //self.isAnimating = false })