我有以下代码,它呈现我的viewcontroller 而不是现有的:
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)
Run Code Online (Sandbox Code Playgroud)
但我想以编程方式将viewcontroller呈现在另一个上面,
有任何想法吗?
Nik*_*kin 38
如果您希望查看模态视图控制器,则必须为其视图提供clear color
背景.并设置modalPresentationStyle
为.OverCurrentContext
.
let vc = storyBoard.instantiateInitialViewController() as! MyPresenterViewController
vc.view.backgroundColor = .clearColor()
vc.modalPresentationStyle = .OverCurrentContext
viewControllerToPresentIn.presentViewController(vc, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我使用以下方法,以便仅在另一个视图控制器的底部显示我的视图:
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)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20459 次 |
最近记录: |