You can still use the binding with getter and setter but not using the short syntax with just the function names : (this could help you if you need to use bindings with getter and setter)
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Toggle("change it", isOn: Binding(get: {
getValue()
},
set: { newValue in
setValue(newValue)
}))
}
.padding()
}
private func getValue() -> Bool {
isOn
}
private func setValue(_ value: Bool) {
isOn = value
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: