测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最新版本 | 2017 年 12 月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由 Sina Moetakef 维护。
版本:1.0.2
SMNumberWheel 是一个为 iOS 定制的控件(继承自 UIControl),用 Swift 编写,适用于选择数字而不仅仅是通过软件键盘手动输入,非常适合快速且准确的选择数字。该轮控件通过与读取用户手指转动角速度工作。您旋转轮子越慢,值变化越精确(高达 4 位小数精确)。旋转速度越快,值的变化也就越快。
示例代码
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)
安装 pod 后
SMNumberWheel
SMNumberWheel
与其他所有小工具一样,您可以从viewController中将一个出口
拖动到您的代码中。为了连接事件,您可以选择以下任意一种方法:
值更改
。extension 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).
}
}
要运行示例项目,首先克隆存储库,然后从Example目录中运行pod install
。
Sina Moetakef,[email protected]
SMNumberWheel在MIT许可下可用。有关更多信息,请参阅LICENSE文件。