ios - 如何呈现较小尺寸的 View Controller

标签 ios swift size frame presentviewcontroller

我想要呈现比屏幕更小的 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/

相关文章:

android - 带有 9-Patch 背景的按钮不包含内容

android - 在显示之前计算 View 尺寸

ios - 无法向本地服务器发出HTTPS请求

ios - 如何修复 Alljoyn iOS SDK 构建失败并出现以下错误?

ios - 如何使用 writeToFile 将图像保存到文档目录中?

ios - 如何在缩放 imageView 时防止缩放 parantView

swift - 如何在 Swift 3 中将 UnsafePointer<[Float]> 或 Float Array 数据转换为 Unsafe[Mutable]Pointer<Float>?

upload - 谷歌云存储 - 如何限制用户上传的大小?

android - 如何检测手机摄像头前的手势识别

ios - 仅在 iOS 8 及更高版本中实现方法