下面的代码显示 SKView
,直到您将 skHeight
更改为 2050 或更高的值(例如 5000)。
1) 如何让 SKView
在 2050 或 5000 的高度上也能显示?
2) SKViews
的最大尺寸是多少?
重现:
1) 运行下面的代码。您将看到表示为灰色窗口的 SKView
。
2) 将skHeight
更改为2050或5000。SKView
不再出现。
class TestViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Create SKView
let skHeight = CGFloat(2050)
let skFrame = CGRect(x: 0, y: 0, width: 100, height: skHeight)
let skView = SKView(frame: skFrame)
skView.backgroundColor = UIColor.red
// Add test view to <scrollView>
view.addSubview(skView)
}
}
最佳答案
OpenGL 渲染在许多设备上不支持大于 4096x4096 的 Canvas 尺寸,您的 View 是 2050x2050,因此当您考虑视网膜模式时,它实际上变成了 4100x4100。
现在 @3x 设备更加疯狂,因为它需要处理硬件缩放和缩小,所以您最终只能获得大约 1501x1501 的 View 。
Metal 没有这个问题,并且从 iOS 12 开始,OpenGL 已被弃用,因此希望模拟器也能使用 Metal。 (应该是因为 Mojave 只支持金属设备)
关于ios - SpriteKit : why does SKView disappear at one height but appears at another height? SKView 的最大高度是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52108374/