HKStepper
描述
HKStepper
的概念类似于 Apple 的 UIStepper
,但拥有更多选项。提供了两种步进器,分别为 HKTimeStepper
用于选择时间,以及 HKValueStepper
用于选择整数值。两者都在按钮之间显示 UILable
中的值。也提供了许多自定义选项。
用法
拖动一个 UIView
对象,并将类设置为 HKTimeStepper
或 HKValueStepper
。确保设置视图大小以便正确显示(最佳大小为 190*40)。现在您可以在 IB 中自定义属性,如图中所示。要通知值变化,请在 ValueChanged
控制事件上创建一个 @IBAction
。
属性
HKTimeStepper
///hours in 24 format
@IBInspectable public var hours: Int = 0
///minutes
@IBInspectable public var minutes: Int = 0
///value added or subtracted in minutes
///(ex 65 is 1 hour and 5 minutes)
@IBInspectable public var stepMinutes: Int = 5
///when enabled, time is shown in 24 hour format
@IBInspectable public var is24: Bool = false
///am value
@IBInspectable public var amText: String = "am"
///pm value
@IBInspectable public var pmText: String = "pm"
/// Color of the text
@IBInspectable public var textColor: UIColor = .darkText
/// Color of the buttons
@IBInspectable public var buttonsColor: UIColor = .darkText
///set font by name
@IBInspectable public var fontName:String = "system"
///set font size
@IBInspectable public var fontSize: CGFloat = 18
///current value
@IBInspectable public var value: Int = 0
///value added or subtracted
@IBInspectable public var stepValue: Int = 5
///minimum value
@IBInspectable public var minValue: Int = 0
///maximum value
@IBInspectable public var maxValue: Int = 50
///text displayed before value
@IBInspectable public var prefix: String = ""
///text displayed after value
@IBInspectable public var postfix: String = ""
/// Color of the text
@IBInspectable public var textColor: UIColor = .darkText
/// Color of the buttons
@IBInspectable public var buttonsColor: UIColor = .darkText
///set font by name
@IBInspectable public var fontName:String = "system"
///set font size
@IBInspectable public var fontSize: CGFloat = 18
HKStepper可以通过CocoaPods获取。在您的podfile中添加以下行:
pod 'HKStepper'
我是Hasan Kassem。我为iOS和Android开发应用程序。
Twitter: @hasankassem_ | Instagram: @hasankassem_ | 邮箱: [email protected]
HKStepper
采用MIT许可证。有关更多信息,请参阅LICENSE文件。