How to change the size of a popover

前端 未结 6 1157
庸人自扰
庸人自扰 2020-12-29 20:17

I\'m having trouble changing the size of my popover presentation. Here is what I have so far

 override func prepareForSegue(segue: UIStoryboardSegue, sender:         


        
6条回答
  •  不思量自难忘°
    2020-12-29 21:02

    Using Auto Layout

    It may be worth mentioning that you can use layout constraints instead of setting preferredContentSize to specific values. To do so,

    1. Add this to your view controller:

      override func viewWillAppear(_ animated: Bool) {
          super.viewWillAppear(animated)
          self.preferredContentSize = self.view.systemLayoutSizeFitting(
              UIView.layoutFittingCompressedSize
          )
      }
      
    2. Ensure that you have constraints from your popover view to the controller's root view. These can be low priority, space >= 0 constraints.

提交回复
热议问题