sharedBackgroundVisibility Not Removing Spacing

Any logical reason why applying .sharedBackgroundVisibility(.hidden) to a ToolbarItem would not remove the spacing allocated for glass border?

Thus causing any element utilizing this functionality to appear offset from the regular buttons.

Or is this yet another magical Apple experience I am not blessed enough to understand.

Hello @jenyalebid

The Discussion section of .sharedBackgroundVisibility documentation says "Hiding the effect will cause the item to be placed in its own grouping."

This might be the cause of the offset.

See this example. The first ToolbarItem has .sharedBackgroundVisibility(.hidden) and it is not offset from the other ToolbarItem.

.toolbar {
    //  Effect hidden
    ToolbarItem(placement: .topBarTrailing) {
        Button(action: {
            //...
        }) {
            Image(systemName: "ant")
        }
    }
    .sharedBackgroundVisibility(.hidden)

    // Effect shown
    ToolbarItem(placement: .topBarTrailing) {
        Button(action: {
            //...
        }) {
            Image(systemName: "ant")
        }
    }
}

Let me know if this helps. Feel free to provide code examples in this thread.

 Travis Trotto - DTS Engineer

If you believe this may be a bug, you can also file a bug report here. Once complete, please post the FB number here for my reference.

If you have any questions about filing a bug report, take a look at Bug Reporting: How and Why?

sharedBackgroundVisibility Not Removing Spacing
 
 
Q