Anybody know how to custom UIButton/UIView hover effect?

UIButton automatically obtains a hover highlight effect in visionOS, but both the highlighted area and the corner radius cannot be customized.

I have attempted to modify the range and corner radius of UIPointerInteraction, but it does not work for visionOS.

Regarding UIView, I have reviewed the documentation and it seems that there is no relevant API.

Anybody know how to custom UIButton/UIView hover effect?

I found this API for iOS 17

if #available(iOS 17.0, *) {
    self.hoverStyle = .init(shape: .capsule)
}

ContentShape to make the outline custom. https://designcode.io/swiftui-handbook-hover-effects

You can customize this by using

.contentShape(.hoverEffect, RoundedRectangle(cornerRadius: 10))
.hoverEffect()

In this case, the hover effect will be a rectangle with rounded edges, but you can replace this with any shape you'd like.

https://developer.apple.com/documentation/swiftui/view/contentshape(::eofill:)

https://developer.apple.com/documentation/swiftui/view/hovereffect(_:)

Anybody know how to custom UIButton/UIView hover effect?
 
 
Q