链接到我的 github 帐户并包含文件,只需下载 zip:https://github.com/jzhang172/modalTest
当我单击“弹出窗口”链接时,我想将弹出窗口置于屏幕中央。
我尝试引用一些 stackoverflow 问题,例如: how to center a popoverview in swift
但没有运气。我是 swift 的菜鸟,我只使用 swift,而不是 Objective C。
最佳答案
更换
controller?.sourceRect = CGRectMake(0.0, self.view.layer.bounds.height * 0.5,0.0,0.0)
与
controller?.sourceRect = CGRectMake(self.view.layer.bounds.width * 0.5, self.view.layer.bounds.height * 0.5,0.0,0.0)
将使弹出框内容水平和垂直居中。
关于ios - Xcode、 swift : How to center popover box,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37195856/