A minimal sliding toggle button SwiftUI Swift Package library.
SlidingToggleButton_Animation.mp4
You can add SlidingToggleButton to your project via Swift Package Manager:
- Open your project in Xcode.
- Navigate to File > Add Package Dependencies.
- Enter the following URL:
https://github.com/TahaTesser/SlidingToggleButton.git
struct ContentView: View {
@State private var isDarkMode = false
var body: some View {
HStack {
// Horizontal Sliding Toggle Button
SlidingToggleButton(
value: $isDarkMode,
startIconName: "sun.max.fill",
endIconName: "moon.fill"
)
// Vertical Sliding Toggle Button
SlidingToggleButton(
value: $isDarkMode,
vertical: true,
startIconName: "sun.max.fill",
endIconName: "moon.fill"
)
}
}
}
SlidingToggleButton is available under the MIT licence. See the LICENCE for more info.