Current version: 1.0.2 [Download]
A collection of custom sliders for SwiftUI.
- RoundSlider gives you a slider that acts as a dial or knob.
- RangeSlider lets you select a range using a slider with two thumbs.
To use Sliders in a project, add this descriptor to the dependencies
list in your Package.swift
file:
.package(url: "https://github.com/timdubbins/sliders", .exact("1.0.2"))
Alternatively, in Xcode, go to:
File > Add Packages...
and enter
https://github.com/timdubbins/sliders
as the package URL.
@State private var myValue = 30.0
@State private var isEditing = false
var body: some View {
RoundSlider(
"title",
value: $myValue,
in: 10...70,
displayBounds: 0...10,
color: .green) {
isEditing = $0
}
}
@State private var lowValue = 0.0
@State private var highValue = 10.0
@State private var isEditing = false
var body: some View {
VStack {
RangeSlider(
lowValue: $lowValue,
highValue: $highValue,
in: 0...10,
showDifferenceOnEditing: true) {
isEditing = $0
}
Text(String(isEditing))
.foregroundColor(isEditing ? .red : .green)
}
.padding()
}
Happy coding!