Skip to content

Instantly share code, notes, and snippets.

Avatar

Nikola Lajic MrNickBarker

View GitHub Profile
@MrNickBarker
MrNickBarker / MyToggle.swift
Created Dec 24, 2019
UISwitch (or Toggle) recreated using SwiftUI with a more playful animation.
View MyToggle.swift
struct MyToggle: View {
@Binding var isOn: Bool
private enum SwitchState {
case notPressed
case pressed(percent: CGFloat)
}
@State private var state: SwitchState = .notPressed
@State private var startPercent: CGFloat?
@State private var pressed = false
You can’t perform that action at this time.