How to make SwiftUI's Picker borderless/transparent on macOS?

Viewed 1121

I want to set a picker button borderless and transparent in SwiftUI on macOS.

I tried using .background(), .border() and .opacity() modifiers on the Picker view. However, I can't change the background to a transparent color using .background(), I can't remove the border using .border(), and I can't find a way to change only the background to transparent using .opacity().

Here is my code for the picker:

Picker(selection: .constant(1), label: EmptyView()) {
    Text("1").tag(1)
    Text("2").tag(2)
}
.scaledToFit()

.constant(1) is a placeholder

Currently the picker looks like this:
Current Picker Look

I want it to look like the pickers in the Contacts app on Mac:
Wanted Picker Look


UPDATE (2019-11-30)

After trying all likely modifiers and functions that are applicable to a Picker, I've determined that there is no solution so far. SwiftUI is incomplete as a replacement for storyboards or XIB as of now.

1 Answers

Try to use .background(.gray .opacity(0.3)) this makes the background color opacity and nothing else,I mean the text will remain the same opacity as before.

Related