Welcome to the documentation for SnappingStepper!
Description
SnappingStepper is a customizable stepper control for iOS applications. It allows users to increment or decrement values by a specified step size. The control snaps to specific values, providing a smoother and more user-friendly experience.
Installation
To integrate SnappingStepper into your Xcode project using CocoaPods, add it to your Podfile:
pod 'SnappingStepper'
Then, run the following command:
pod install
If you prefer using Carthage, add the following line to your Cartfile:
github "vmanot/SnappingStepper"
Then, run the following command:
carthage update
Usage
To use SnappingStepper in your project, follow these steps:
- Create an instance of SnappingStepper and add it to your view hierarchy.
- Set the minimum and maximum values for the stepper.
- Set the step size for the stepper.
- Optionally, set the initial value for the stepper.
- Subscribe to the valueChanged event to be notified when the value is changed.
Example
Here is an example of how to use SnappingStepper:
import SnappingStepper
// Create an instance of SnappingStepper
let snappingStepper = SnappingStepper(frame: CGRect(x: 0, y: 0, width: 200, height: 50))
// Set the minimum and maximum values
snappingStepper.minimumValue = 0
snappingStepper.maximumValue = 10
// Set the step size
snappingStepper.stepValue = 1
// Optionally, set the initial value
snappingStepper.value = 5
// Subscribe to the valueChanged event
snappingStepper.addTarget(self, action: #selector(valueChanged(_:)), for: .valueChanged)
// Add the SnappingStepper to your view hierarchy
view.addSubview(snappingStepper)
@objc func valueChanged(_ stepper: SnappingStepper) {
// Handle the value change event
print("Value changed: \(stepper.value)")
}
Customization
SnappingStepper offers a range of customization options:
Colors
The following properties allow you to customize the colors:
backgroundColor
: The background color of the stepper.thumbColor
: The color of the thumb.highlightedThumbColor
: The color of the thumb when highlighted.
Fonts
The following properties allow you to customize the fonts:
valueLabelFont
: The font of the value label.unitLabelFont
: The font of the unit label.
Appearance
The following properties allow you to customize the appearance:
cornerRounding
: The corner rounding of the stepper.showValueLabel
: A boolean value indicating whether to show the value label.showUnitLabel
: A boolean value indicating whether to show the unit label.
Use these properties to customize the appearance of SnappingStepper to match your app’s design.
Conclusion
SnappingStepper is a powerful and customizable stepper control for iOS applications. With its snapping behavior and various customization options, it provides a great user experience. We hope this documentation has been helpful in getting started with SnappingStepper.