[self transitionFromViewController:oldController toViewController:newController duration:0.0 options:0 animations:nil completion:nil];

/*

This method can be used to transition between sibling child view controllers.

The receiver of this method is their common parent view controller. (Use [UIViewController

addChildViewController:] to create the parent/child relationship.) This method will add the toViewController's view to the superview of the fromViewController's view and the fromViewController's view will be removed from its superview after the transition completes. It is important to allow this method to add and remove the views. The arguments to this method are the same as those defined by UIView's block animation API. This method will fail with an NSInvalidArgumentException if the parent view controllers are not the same as the receiver, or if the receiver explicitly forwards its appearance and rotation callbacks to its children. Finally, the receiver should not be a subclass of an iOS container view controller. Note also that it

is possible to use the UIView APIs directly. If they are used it is important to ensure that the

toViewController's view is added to the visible view hierarchy while the fromViewController's view is removed.

*/

- (void)transitionFromViewController:(UIViewController*)fromViewController toViewController:(UIViewController*)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void(^__nullable)(void))animations

completion:(void(^__nullable)(BOOLfinished))completionNS_AVAILABLE_IOS(5_0);



/**

*切換控制器

*

*? @param oldController舊控制器

*? @param newController新控制器

*/

- (void)replaceController:(QDFViewController*)oldController newController:(QDFViewController*)newController

{

/**

*著重介紹一下它

*

transitionFromViewController:toViewController:duration:options:animations:completion:

*? fromViewController當(dāng)前顯示在父視圖控制器中的子視圖控制器

*? toViewController將要顯示的姿勢圖控制器

*? duration動畫時間(這個屬性,old

friend了O(∩_∩)O)

*? options動畫效果(漸變,從下往上等等,具體查看API)

*? animations轉(zhuǎn)換過程中得動畫

*? completion轉(zhuǎn)換完成

*/

if(newController == oldController) {

return;

}

oldController.visible=NO;

newController.visible=YES;

[self addChildViewController:newController];

if(!oldController) {

[self.rightPlaceholderView addSubview:newController.view];

self.currentVC = newController;

}

else{

[self ?transitionFromViewController:oldController toViewController:newController duration:0.0 options:0 animations:nil completion:nil];

[newController didMoveToParentViewController:self];

[oldController willMoveToParentViewController:nil];

[oldController removeFromParentViewController];

self.currentVC = newController;

}

[newController.view mas_makeConstraints:^(MASConstraintMaker*make) {

make.edges.equalTo(self.rightPlaceholderView);

}];

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • ViewsBecause view objects are the main way your applicati...
    梁光飛閱讀 641評論 0 0
  • 觀察者模式是指一個或者多個對另外一個對象進行觀察,當(dāng)觀察對象發(fā)生變化時,觀察者可以直接或者間接地得到通知,從而能自...
    司夜閱讀 205評論 1 0
  • 互聯(lián)網(wǎng)時代,每個人都知道要快,快速出方案、快速設(shè)計、快速開發(fā)、快速上線、快速迭代。跑得快的吃肉喝湯,跑得慢連骨頭都...
    無邪閱讀 1,469評論 0 3
  • 有個男孩愛上一位女神 那個男孩每天買早餐送到女神面前與女神共進早餐! 晚上陪女神逛街,看電影,送女神回家。充當(dāng)女神...
    葉子隨風(fēng)流逝閱讀 675評論 4 3
  • 對于一個人來說,你的個人商業(yè)模式路線圖可以簡單概括如下: 給別人打工,找個買家出售自己的時間——給老板打工的同時給...
    酒慰風(fēng)雨夕閱讀 245評論 0 0