You cannot hide the button Show less / Show more
if you change the display mode.
However, if you set the widget display mode to the maximum available, it should hide it:
self.extensionContext?.widgetLargestAvailableDisplayMode = .compact
source
to share