Can anyone tell me how to achieve the effect in the picture below. The two Views actually belong to the same Window, but they are separate effects instead of contained effects.
By default windows automatically get a glass background spanning all their size, but you can change this in SwiftUI using .windowStyle(.plain)
. Then, you can manually apply the glass background to the views that you wish using .glassBackgroundEffect()
. Here is an example of what it would look like:
struct MyApp: App {
var body: some Scene {
WindowGroup {
VStack {
TopView()
.glassBackgroundEffect()
BottomView()
.glassBackgroundEffect()
}
}
.windowStyle(.plain)
}
}
Alternatively, ornaments allow you to place accessory content all around your window as well, but their size is independent of the window size.