我想展示比屏幕更小的视图控制器vc2,如何在Swift 3中做到??谢谢你的帮助。这是我的代码:
@IBAction func leftButtonPressed(_ sender: UIButton) {
let vc2 = self.storyboard?.instantiateViewController(withIdentifier: "Controller2") as! ViewController2
vc2.modalPresentationStyle = .currentContext
present(vc2, animated: true, completion: nil)
}发布于 2017-06-21 10:50:28
试试这个..。
@IBAction func leftButtonPressed(_ sender: UIButton) {
let vc2 = self.storyboard?.instantiateViewController(withIdentifier: "Controller2") as! ViewController
vc2.providesPresentationContextTransitionStyle = true
vc2.definesPresentationContext = true
vc2.modalPresentationStyle=UIModalPresentationStyle.overCurrentContext
self.present(vc2, animated: true, completion: nil)
// Make sure your vc2 background color is transparent
vc2.view.backgroundColor = UIColor.clear
}发布于 2017-06-21 08:03:52
您可以简单地使用容器视图来显示较小的视图控制器。这里有一个关于容器视图的很好的教程:https://cocoacasts.com/managing-view-controllers-with-container-view-controllers/
希望这能对您有所帮助:)
https://stackoverflow.com/questions/44663002
复制相似问题