0

I'm trying to make a visionOS window have an opaque image background setting. I have achieved this but the corners never match, they remain sharp and beyond the window shape.

I have used:

import SwiftUI
import RealityKit
import RealityKitContent
@main
struct BackgroundImageApp: App {
 var body: some Scene {
 WindowGroup {
 ContentView()
 }
 .defaultSize(width: 600, height: 400)
 }
}
struct ContentView: View {
 var body: some View {
 VStack {
 Text("Hello, VisionOS!")
 .font(.largeTitle)
 .foregroundStyle(.white)
 .padding()
 }
 .frame(maxWidth: .infinity, maxHeight: .infinity)
 //the backgrond image addition
 .background(
 Image("studio")
 .resizable()
 .scaledToFill()
 .clipped()
 .cornerRadius(24)
 )
 }
}

As well as various versions of Vstack settings.

It did place the image as the background (and playing with the opacity settings worked) but the corners never fitted.

HangarRash
16.7k5 gold badges31 silver badges64 bronze badges
asked Apr 30, 2025 at 11:24
2
  • Try showing the image as an overlay over Color.clear, see this answer for details. Ps, the modifier .cornerRadius is deprecated, use a RoundedRectangle as clip shape instead. Commented Apr 30, 2025 at 13:20
  • clipShape modifier to the image with ContainerRelativeShape may help Commented May 3, 2025 at 22:12

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.