Existing ViewController on top of other software

I have the following code that my view manager represents instead of the existing one:

let frameworkBundle = NSBundle(identifier: "me.app.MyFramework") var storyBoard:UIStoryboard = UIStoryboard(name: "MyStoryboard", bundle: frameworkBundle) var vc = storyBoard.instantiateInitialViewController() as MyPresenterViewController viewControllerToPresentIn.presentViewController(vc, animated: true, completion: nil) 

But I want to present the viewcontroller on top of another programmatically,

any ideas?

+8
ios swift
source share
3 answers

If you want your modal view manager to display, although you need to specify its background clear color . And set its modalPresentationStyle to .OverCurrentContext .

 let vc = storyBoard.instantiateInitialViewController() as! MyPresenterViewController vc.view.backgroundColor = .clearColor() vc.modalPresentationStyle = .OverCurrentContext viewControllerToPresentIn.presentViewController(vc, animated: true, completion: nil) 
+22
source share

I used the following approach to present my view only at the bottom of another view controller:

 var presenterStoryBoard:UIStoryboard = UIStoryboard(name: "MiniAppPanel", bundle: frameworkBundle) var vc = presenterStoryBoard.instantiateInitialViewController() as MiniAppPanelViewController vc.view.frame = CGRectMake(0, vc.view.frame.size.height - 120, vc.view.frame.size.width, 120) publisherViewController.addChildViewController(vc) publisherViewController.view.addSubview(vc.view) 
+3
source share

If you use a navigation controller, you can change the viewcontrollers as

  navigationController?.presentViewController(newVC, animated: true, completion: nil) 

but since the view doesn’t lead to a left or right view, you’ll lose your navigation controller

0
source share

All Articles