One Logo Pool Ball
SwiftUI · IOS API REFERENCE

HoverPhase

enum · iOS 16.0+ · SDK 27.1

@frozen enum HoverPhase

The current hovering state and value of the pointer. When you use the ``View/onContinuousHover(coordinateSpace:perform:)`` modifier, you can handle the hovering state using the `action` closure. SwiftUI calls the closure with a phase value to indicate the current hovering state. The following example updates `hoverLocation` and `isHovering` based on the phase provided to the closure: @State private var hoverLocation: CGPoint = .zero @State private var isHovering = false var body: some View { VStack { Color.red .frame(width: 400, height: 400) .onContinuousHover { phase in switch phase { case .active(let location): hoverLocation = location isHovering = true case .ended: isHovering = false } } .overlay { Rectangle() .frame(width: 50, height: 50) .foregroundColor(isHovering ? .green : .blue) .offset(x: hoverLocation.x, y: hoverLocation.y) } } }

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →