Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 1.72 KB

README.md

File metadata and controls

83 lines (63 loc) · 1.72 KB

Sliders

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.

me

Getting Started

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.

Examples

RoundSlider

@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
        }
}

RangeSlider

@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!