Hi all,
I’m experiencing a visual bug when applying the glass effect to a Label in Liquid Glass (current version 26.2 on simulator; also reproducible in 26.3.1 on device).
Issue:
On a label with .glassEffect(.regular), when collapsing via morph animation, the shadow is clipped during the animation, and then suddenly "pops" back to its un-clipped state, resulting in a jarring visual effect.
Minimal Example:
import SwiftUI
struct ContentView: View {
var body: some View {
Menu {
Button("Duplicate", action: {})
Button("Rename", action: {})
Button("Delete…", action: {})
} label: {
Label("PDF", systemImage: "doc.fill")
.padding()
.glassEffect(.regular)
}
}
}
#Preview {
ContentView()
}
I am not sure if I am misusing the .glassEffect() on the label and maybe there is another more native way of achieving this look? Any advice or workaround suggestions would be greatly appreciated!
It seems like there are two ways of approaching this.
One (bad one) is: Adding the padding on the label view to compensate the native shadow.
Menu {
Button("Duplicate", action: {})
Button("Rename", action: {})
Button("Delete…", action: {})
} label: {
Label("PDF", systemImage: "doc.fill")
.padding()
.glassEffect(.regular)
.padding(40) // <- Here
}
Another one, much better:
Menu {
Button("Duplicate", action: {})
Button("Rename", action: {})
Button("Delete…", action: {})
} label: {
Label("PDF", systemImage: "doc.fill")
.padding()
.glassEffect(.clear)
}
Both have tradeoffs, one is a spatial one, since you have to provide space for it, but maybe useful for someone who is not constrained by space.
Another one - visual, since the glass effect .clear, doesn't have a frost. I guess this could be improved by overlaying a white color with low opacity to simulate the same effect.