TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Dec 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Sina Moetakef.
version: 1.0.2
SMNumberWheel is a custom made control (subclass of UIControl) for iOS, written in Swift, which is ideal for picking numbers instead of typing them by software keyboards. The main idea is to be able to pick numbers very fast and and yet accurate. The wheel works with reading the angular speed of user’s finger. The slower you spin the wheel, the more accurate values are changed (up to 4 fraction digits accurate). The more rotation speed results in exponentially faster value changes.
Sample code:
let wheel = SMNumberWheel(frame: CGRect(x: 100, y: 100, width: 180, height: 180))
wheel.majorIndicators = 4
wheel.majorIndicatorType = .diamond
wheel.minorIndicatorType = .none
wheel.ringColor = UIColor.red
wheel.strokeColor = UIColor.red
wheel.stepper = false
wheel.hapticFeedback = true
// continue setting up the properties ...
wheel.delegate = self
self.view.addSubview(wheel)
After installing the pod:
SMNumberWheel
SMNumberWheel
Like all other widgets, you can easily drag an outlet
from the viewController to your code. In order to connect events, you can use either of the following methods:
Value Changed
as event typeextension viewController : SMNumberWheelDelegate {
func SMNumberWheelDidResetToDefaultValue(_ numberWheel: SMNumberWheel) {
// Happens when the central button is tapped and the wheel is set to it's initial value
}
func SMNumberWheelValueChanged(_ numberWheel: SMNumberWheel) {
// Happens when the value of the wheel changes.
}
func SMNumberWheelReachedLimit(_ numberWheel: SMNumberWheel, stayedAtLimit: Bool) {
// Notifies the developer that the value of the wheel has reached one of the limits.
}
func SMNumberWheelStepperKeyPressed(_ numberWheel: SMNumberWheel, rightKey: Bool) {
// Notifies that a tap on one of the stepper keys is detected.
// rightKey == true -> tapped on right key, otherwise tapped on the left key.
}
func SMNumberWheelChangedAppearance(_ numberWheel: SMNumberWheel, minimized: Bool) {
// Notifies the developer that the visual state of the wheel is changed (minimized or maximized).
}
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
Sina Moetakef, [email protected]
SMNumberWheel is available under the MIT license. See the LICENSE file for more info.