If you want to use VisionOS' standard highlight effects in your iPhone app, you may need to configure the controls in SwiftUI correctly. Standard UIKit controls usually provide hover effects automatically, but some additional steps may be required to achieve these effects in SwiftUI. Here are some points to consider in this regard:
Using Button Control: When using Button in SwiftUI, you can use buttonStyle modifier to achieve the highlighting effect. For example:
Button(action: addSketch) {
Image(systemName: "plus.circle")
.resizable()
.frame(width: roundIconDia, height: roundIconDia)
.padding([.leading, .trailing], 20)
}
.buttonStyle(.plain) // Plain button style is used for highlighting effect
The standard highlight effect can be achieved by specifying buttonStyle(.plain).
If you use controls on the navigation stack, such as the back button or tab view, with NavigationLink, you will automatically get the highlight effect. However, if you are customizing buttons, you may need to use the buttonStyle modifier.
Some controls in SwiftUI, specifically buttons (Button) and navigation links (NavigationLink), provide automatic highlighting effects. However, if you are using some customized button styles or controls, you can specify visual behaviors using modifiers like buttonStyle or onChange.
The hover effect is typically triggered by user touch or mouse interaction. Be sure to use appropriate icon and color combinations to ensure your controls are highlighted.
In SwiftUI, the hoverEffect() modifier is used to determine how the control behaves when the user hovers over it. However, it may be more effective to use the buttonStyle() or onChange() modifiers directly for the highlighting effect.