SwiftUI Error: Unintentional gray hit box float on SwiftUI Button&NavigationLink in iOS 15 devices

Hi, our team is struggling in unintentional UI error of SwiftUI.

There has never been a problem like this before. However, it occurred after the iOS 15 update.

There is awkward gray box shape is floating on only SwiftUI Button, and NavigationLinks. You can see that in this image. This is a real image of Run of our app.

'a' is Empty NavigationLink like below code.

NavigationLink(destination: EmptyView()) {
  EmptyView()
}

As you can check in code, there should not be floating gray box. Since both the destination and label are EmptyView, they must not be visible. However it is exposed to users, perhaps because of an error.

'b' is pure Image().

'c' is Button containing Image.

Button(action: action) {
  Image("icon_bubble")
}.frame(width: 48, height: 48)

These code seems that never makes this gray box but it generates on Button and NavigationLink in SwiftUI.

This problem not occurs in every devices, but some iOS 15 devices have this problem. Although users install same app by same route, this box is reveal to specific user.

  • There is no box in my iPhone 13 and 13 mini but it is represented in my teammate's iPhone X and 13 mini.

We see the View Debugger by Reveal.

This Box is SwiftUI.UIShapeHitTestingView in SwiftUI.UIInheritedView. In this app, we don't set any hit testing options in project. But HitTestingView is presented to some specific devices.

Is there anyone how to solve this problem? How to process the UIShapeHitTestingView is hidden?

I wonder why some device display the box and other not even though they are on same condition(iOS version, Device, App Version).

I have the exact same issue. Were you able to find a solution for this? I have seen this come up sporadically for users on various devices/iOS versions.

Thanks!

Have you resolved this? It still occurs on my device (iphone 14 Pro and iOS 16.3)

I have the same issue. Gray boxes on buttons and pickers. In additional on the small percentage of users that have this issue, the view expands horizontally so it overflows slightly on the side. Can't seem to replicate the issue based on iOS version of device. Any progress?

I'm having the same issue on the Landmarks app creating in Introducing SwiftUI tutorial.

This is screenshot taken from my physical iPhone 14 Pro Max:

And this is the same screen on iPhone 14 Pro Max simulator:

How do I remove that gray box?

In our case the configuration 'Button Shapes' was on. Turning it off solved the problem.

SwiftUI Error: Unintentional gray hit box float on SwiftUI Button&NavigationLink in iOS 15 devices
 
 
Q