Sample Code:
struct CustomToggleButton: View {
@Binding var isSwitchOn: Bool
var body: some View {
Button(action: {
isSwitchOn.toggle()
}){
HStack {
Image(systemName: isSwitchOn ? "checkmark.circle.fill" : "circle")
.resizable()
.frame(width: 20, height: 20)
//Text(isSwitchOn ? "On" : "Off")
}
}
}
}
Usage:
struct ContentView: View {
@State private var toggleState = false
var body: some View {
CustomToggleButton(isSwitchOn: $toggleState)
}
}
No comments:
Post a Comment