代码之家  ›  专栏  ›  技术社区  ›  Enamul Haque

如何自下而上呈现局部高度模态视图控制器

  •  4
  • Enamul Haque  · 技术社区  · 6 年前

    我使用视图控制器作为模态。我想指定它从下到上的高度。这意味着它从底部向高处打开。我使用了下面的代码打开模式:

    let popUpVc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "NewController") as! NewController
    self.addChildViewController(popUpVc)
    //Transition from bottom
    let transition = CATransition()
    transition.duration = 0.5
    transition.type = kCATransitionPush
    transition.subtype = kCATransitionFromTop
    view.window!.layer.add(transition, forKey: kCATransition)
    
    popUpVc.view.frame = self.view.frame
    self.view.addSubview(popUpVc.view)
    popUpVc.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
    popUpVc.didMove(toParentViewController: self)
    

    1 回复  |  直到 6 年前
        1
  •  14
  •   Ashley Mills    6 年前

    显示 按钮以模式呈现包含的视图控制器,呈现类型为 过流上下文 .

    @IBAction func unwind(_ segue: UIStoryboardSegue) { }
    

    只要一行代码!