-
-
Save sturdysturge/0b3557d78837817f5df19ba783d2a0fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| @available(iOS 16.0, *) | |
| struct ContentView: View { | |
| @State var sliderValue = Double(0) | |
| var body: some View { | |
| VStack { | |
| Text(String(sliderValue)) | |
| Slider(value: $sliderValue, in: 0...100) | |
| CustomSlider(value: $sliderValue, in: 0...100) | |
| } | |
| } | |
| } | |
| struct CustomSlider: View { | |
| @Binding var value: Double | |
| let bounds: ClosedRange<Double> | |
| internal init(value: Binding<Double>, | |
| in bounds: ClosedRange<Double>) { | |
| self._value = value | |
| self.bounds = bounds | |
| } | |
| var body: some View { | |
| ZStack { | |
| ProgressView(value: value / bounds.upperBound) | |
| .padding(.horizontal, 1) | |
| SliderThumbView(value: $value, bounds: bounds) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment