Using a Toggle to disable/enable a slider is resulting in the styling being inverted until you interact with the Slider. I'm obviously going about this the wrong way!
struct ContentView: View {
@State var isActive = true
@State var value :Double = 2.0
var body: some View {
VStack {
Section(header:
HStack {
Toggle(isOn: $isActive)
{}.toggleStyle(SwitchToggleStyle(tint: .purple))
}
) {
HStack {
Slider(value: $value, in: 0...4, step: 1)
.accentColor(isActive ? .purple : .secondary).disabled(!isActive)
}.pickerStyle(SegmentedPickerStyle())
}
}
}
}
Disable the toggle - note the Slider style is wrong, but the colour is correct
If you interact with the re-enabled slider, the styling fixes itself.
I hope I'm doing something daft here...