swiftswiftuiios-simulatoripados

SwiftUI .hoverEffect on view with Material background blacks out view


I have a view with a material background fill. When applying a hoverEffect to this view, the view becomes blacked out on hover.

Demonstration

Very minimal reproducible code:

ZStack {
    Rectangle()
        .fill(Material.thinMaterial)
    
    Text("lift")
}
.hoverEffect(.lift)


ZStack {
    Rectangle()
        .fill(Material.thinMaterial)
    
    Text("highlight")
}
.hoverEffect(.highlight)

I'm not sure if this is intended behaviour, as .lift is stated to produce "An effect that ... as the view scales up and gains a shadow." However, the same things happens with .highlight, where it is not supposed to produce any shadows under the view when hovered.

Note: This happens on real hardware and within simulators. I have tested in iPadOS 16.1 and 15.5 simulators, and I can replicate this behaviour in both.

Any help is appreciated. Thanks!


Solution

  • Seems to be fixed in versions >16.3!