【问题标题】:Swift Modal View Controller with transparent background going beyond tab bar具有超越标签栏的透明背景的 Swift 模态视图控制器
【发布时间】:2018-03-29 05:56:41
【问题描述】:

我在 gist 中尝试了相同的代码:https://gist.github.com/barbietunnie/e5547f35180436ac102cac52a15f8ca3

func showModal() {
    let modalViewController = ModalViewController()
    modalViewController.modalPresentationStyle = .OverCurrentContext
    presentViewController(modalViewController, animated: true, completion: nil)
}

class ModalViewController: UIViewController {
    override func viewDidLoad() {
        view.backgroundColor = UIColor.clearColor()
        view.opaque = false
    }
}

它工作正常,但在标签栏的情况下,内容超出了标签栏,我们如何使内容在标签栏的上方/前面可见?

【问题讨论】:

  • 你能添加一张你得到的截图吗?

标签: ios swift presentmodalviewcontroller


【解决方案1】:

它通过vc.modalPresentationStyle = .overFullScreen工作

【讨论】:

    【解决方案2】:

    希望对你有用,

    let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let controller = mainStoryboard.instantiateViewController(withIdentifier:  "ModalViewController") as! ModalViewController
    controller.modalPresentationStyle = .overCurrentContext
    

    谢谢。

    【讨论】:

      猜你喜欢
      • 2016-01-11
      • 2015-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多