Fullscreen view in watchOS with SwiftUI

对着背影说爱祢 提交于 2021-02-02 03:46:29

问题


I wan't to display a SwiftUI View as fullscreen in watchOS (without the Cancel/Back Button or Clock)

I've tried adding a Sprite Kit Scene to the view and also setting the .edgesIgnoringSafeArea(.all) but I'm still able to hide them or put a view under the top bar.


回答1:


Unless it's a game, it's not possible to strip out the space at the top, watchOS reserves it so that the time is always visible to the user.




回答2:


Turns out it does "work", even with SwiftUI:

Using Interface Builder: https://developer.apple.com/documentation/watchkit/wkinterfaceskscene/configuring_a_watchkit_scene_in_a_storyboard

Using SwiftUI (watchOS 7):

@main
struct BitApp: App {
  @SceneBuilder var body: some Scene {
    WindowGroup {
      ContentView()
        .edgesIgnoringSafeArea(.all)
    }

    WKNotificationScene(controller: NotificationController.self, category: "myCategory")
  }
}

Remove any NavigationView and use edgesIgnoringSafeArea and it works!

Edit: It won't remove the clock though, as it will be positioned in the corner in front of the SpriteKit scene.



来源:https://stackoverflow.com/questions/58336885/fullscreen-view-in-watchos-with-swiftui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!