Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a modifier to change the label color of SwiftUI Picker?

Tags:

ios

swift

swiftui

I want to change the label color of SwiftUI Picker from blue to black, tried .foregroundColor(.black) and .tint(.black), but the color remains blue.

@State var privacy = Privacy.open
enum Privacy: String, CaseIterable, Identifiable {
    case open = "Open"
    case closed = "Closed"
    var id: String {
        self.rawValue
    }
}
    
var body: some View {
    Picker("privacy", selection: $privacy) {
        ForEach(Privacy.allCases) { value in
            Text(value.rawValue)
                .tag(value)
        }
    }
    .pickerStyle(.menu)
    .tint(.black)
    .foregroundColor(.black)
}

like image 598
Fawzi Rifai Avatar asked Dec 21 '25 18:12

Fawzi Rifai


1 Answers

I tried foregroundStyle and accentColor and only accentColor worked. It does have a future deprecation warning, but you should be able to use it for now.

.accentColor(.orange)
like image 113
EmilioPelaez Avatar answered Dec 23 '25 07:12

EmilioPelaez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!