I have the following code which present my viewcontroller instead of an 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 the other one programmatically,
any ideas?
If you want your modal view controller to be see-though you have to give its view a clear color
background. 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)
I used the following approach in order to present my view only on the bottom of the other 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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With