A draggable stepper controller for macOS
[中文版本]
This package lets you to use draggable steppers like on macOS 15 to control digital inputs on older macOS
macOS 11.0+
Add https://github.com/lihaoyun6/DragSteper
to your project using Swift Package Manager in Xcode
First, import DragSteper
into your code:
import DragSteper
Then you can:
import SwiftUI
import DragSteper
struct ContentView: View {
@State var number: Int = 0
@State var isPresented: Bool = false
var body: some View {
HStack {
TextField("Test", value: $number, formatter: NumberFormatter())
.popover(isPresented: $isPresented) {
DragSteper(value: $number)
}
Button("Edit") {
isPresented = true
}
}.padding()
}
}
When you click this button, a draggable stepper will pop up for fine-tuning the bound value.
You can also control the range using the minValue
and maxValue
parameters, or enable haptic feedback by adding haptic: true
:
...
DragSteper(value: $number, minValue: 1, maxValue: 100, haptic: true)
...