我想要呈现比屏幕更小的 View Controller 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)
}
最佳答案
试试这个..
@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
}
关于ios - 如何呈现较小尺寸的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44663002/