ios - Xcode、 swift : How to center popover box

标签 ios xcode swift popover

链接到我的 github 帐户并包含文件,只需下载 zip:https://github.com/jzhang172/modalTest

当我单击“弹出窗口”链接时,我想将弹出窗口置于屏幕中央。

我尝试引用一些 stackoverflow 问题,例如: how to center a popoverview in swift

但没有运气。我是 swift 的菜鸟,我只使用 swift,而不是 Objective C。

我看到的截图: enter image description here

最佳答案

更换

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/

相关文章:

ios - swift NSURLSession : trouble when running multiple requests at the same time

ios - 如何创建带格式的字符串?

ios - 下载外部网页,用js和css修改,然后加载到 View 中的最佳方法

swift - 当导航栏中的 UI 开关更改时更改标题中的标签

objective-c - iOS6自动旋转困惑以及对iOS5的支持

ios - 在不提交的情况下更改对象的属性

css - RetinaJS 和 LESS : Background image doesn't show on iOS

ios - 在代码中设置 "User Defined Runtime Attributes"

xcode - Homebrew 找不到已安装的命令行工具

ios - 以编程方式使用 ScrollView