Open hunter-ji opened 3 years ago
var window = NSScreen.main?.visibleFrame
HStack { } .frame(width: window!.width / 2.0, height: window!.height / 1.5)
struct Home: View { var window = NSScreen.main?.visibleFrame var body: some View { HStack { Text("Hello, World!") } .frame(width: window!.width / 2.0, height: window!.height / 1.5) } }
一. 代码实现
1. 获取屏幕对象
2. 设置大小
二. 汇总