visionOS: ornament and resize window

I created a window with the following code

        WindowGroup {
            MainView()
                .ornament(attachmentAnchor: .scene(alignment: .bottom)) {
                    OrnementView(title: "Bottom")
                }
                .ornament(attachmentAnchor: .scene(alignment: .top)) {
                    OrnementView(title: "Top")
                }
                .ornament(attachmentAnchor: .scene(alignment: .leading)) {
                    OrnementView(title: "Leading")
                }
                .ornament(attachmentAnchor: .scene(alignment: .trailing)) {
                    OrnementView(title: "Trailing")
                }
                .frame(minWidth: 100, maxWidth: 400, minHeight: 100, maxHeight: 400)
                .border(.green)
        }

It shows me this

When I resize my Window the ornaments do not follow the Window

Post not yet marked as solved Up vote post of ZeTof Down vote post of ZeTof
1.7k views
  • I am having the same issue, @ZeTof did you find any solution?

Add a Comment

Replies

Hello, same for me here. The only workaround I found is to wrap the main view in a GeometryReader and set each ornaments‘ frame proportionally to the proxy’s width and height. But that seems like an odd default behavior. For instance, tool bars and tab bars as ornaments resize and set their position relative to the window automatically.

Hey guys, did you guys ever find a solution that works, that will keep the resized shape in simulation? Thanks!

Related issue: Unable to set initial/default window size

WindowGroup {
    ContentView()
        .frame(width: 300, height: 400) // imperfect, the ornaments still layout as the original size
}
.windowStyle(.plain)
.defaultSize(width: 1.5, height: 2, depth: 0, in: .meters) // no effect on plain window
  • Hey Gong, thanks for the help. Yea figured out the windowstyle(.plain) was the problem.

    Would you happen to know how i could have diffrent views with diffrent sizes.

    It seems to change all my view to that certain size. Thanks!

Add a Comment