问题
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