how to center a popoverview in swift

前端 未结 10 1744
终归单人心
终归单人心 2020-12-04 16:42

I have the following code to show a popoverview (dialog) without an arrow, which works fine. The only problem is, that the dialog is shown in the top left (IPad). I would li

10条回答
  •  天涯浪人
    2020-12-04 17:19

    Swift 4 implementation :

    popover.popoverPresentationController?.sourceRect = CGRect(x: view.center.x, y: view.center.y, width: 0, height: 0)
    popover.popoverPresentationController?.sourceView = view
    popover.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
    

提交回复
热议问题