在全屏模式下以Swiftui的形式展示模式,并防止关闭它
我有一个 SplashView,它充当起始视图并以模式打开游戏屏幕。
我只是尝试在 iPad 而不是 iPhone 上打开游戏,但视图看起来很奇怪。
当我切换到游戏屏幕时,屏幕显示为中间的小屏幕,我可以将其滑出以将其关闭。逻辑中的其他屏幕堆叠在该屏幕上。
如何防止堆叠并使所有屏幕全屏,类似于我在 iPhone 上打开它并防止通过滑动移动它们?
.sheet(isPresented: $isPlayerDashboardModal) {
if let playerState = PlayerViewModel.createNewGameData(name: playerName) {
let playerViewModel = PlayerViewModel(player: playerState)
CityView(viewModel: playerViewModel)
}
}.frame(minWidth: DeviceTypes.ScreenSize.width, idealWidth: DeviceTypes.ScreenSize.width, maxWidth: DeviceTypes.ScreenSize.width, minHeight: DeviceTypes.ScreenSize.height, idealHeight: DeviceTypes.ScreenSize.height, maxHeight: DeviceTypes.ScreenSize.height, alignment: .center)
我已经将框架设置为最大,但这似乎没有做任何事情。
I have a SplashView that acts as a starting view and opens the game screen in modals.
I just tried to open the game in an iPad instead of iPhone and the views look all weird.
When I switch to the game screen the screen is presented as a small screen in the middle and I can swipe it out to close it. Other screens from the logic are stacked on this screen.
How can I prevent the stacking and have all screen in full screen, similar to when I open it on an iPhone and prevent moving them by swiping?
.sheet(isPresented: $isPlayerDashboardModal) {
if let playerState = PlayerViewModel.createNewGameData(name: playerName) {
let playerViewModel = PlayerViewModel(player: playerState)
CityView(viewModel: playerViewModel)
}
}.frame(minWidth: DeviceTypes.ScreenSize.width, idealWidth: DeviceTypes.ScreenSize.width, maxWidth: DeviceTypes.ScreenSize.width, minHeight: DeviceTypes.ScreenSize.height, idealHeight: DeviceTypes.ScreenSize.height, maxHeight: DeviceTypes.ScreenSize.height, alignment: .center)
I set the frame to max already, but this does not seem to do anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 .sheet 替换为 .fullScreenCover 以确保窗口全屏且无法通过下拉关闭。
要隐藏 iPad 上的状态栏,请在最终视图关闭之前添加: .statusBar(hidden: true) 。
replace .sheet with .fullScreenCover to ensure that window is full screen and cannot be closed via pulling it down.
To hide the statusbar on iPad include: .statusBar(hidden: true) before the final view closure.