gpt4 book ai didi

swift - 如何在Mac Catalyst下获取sceneWindow的大小和位置

转载 作者:行者123 更新时间:2023-11-30 10:33:10 27 4
gpt4 key购买 nike

当我使用调整场景窗口大小时,我已经能够获取场景窗口的大小

func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) {
print("movement trapped \(windowScene.coordinateSpace.bounds)"
}

在场景委托(delegate)中。但无论我将窗口拖动到哪里,x,y 坐标始终为 0,0。希望能够指定新的 sceneWindow 在 Mac 屏幕上相对于“默认”sceneWindow 的位置。

最佳答案

您可以尝试将窗口框架从windowScene坐标空间转换为UIScreen坐标空间

windowFrame = [window convertRect:window.frame toCoordinateSpace:window.windowScene.screen.coordinateSpace];

关于swift - 如何在Mac Catalyst下获取sceneWindow的大小和位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58654932/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com