The glassEffect view modifier puts Liquid Glass on any view. Glass is not a static background:
it reacts to the content behind it, and can even flip the view's color scheme between light and
dark as different content scrolls past.
One modifier
ScrollView { /* content */ }
.safeAreaInset(edge: .bottom) {
Text("Hello, World!")
.padding()
.glassEffect()
}
}
Three Glass variants
The Glass type ships regular, clear, and identity. regular is the system default,
clear is more transparent, and identity renders no glass, which makes conditional toggling
clean.
.glassEffect(isEnabled ? .regular : .identity)
Tint and interactivity
tint blends a color into the glass. interactive() makes the glass respond more strongly to
the content behind it and handle gestures such as tap and drag; use it on glass that acts as a
control.
.glassEffect(.clear.tint(.red))
.glassEffect(.clear.interactive())
Shape
The second parameter sets the glass shape, DefaultGlassEffectShape unless you pass one.
.glassEffect(.clear, in: .circle)