@@ -11,10 +11,17 @@ import UIKit
1111@IBDesignable public class GMStepper: UIControl {
1212
1313 /// Current value of the stepper. Defaults to 0.
14− @IBInspectable public var value = 0 {
14+ @IBInspectable public var value: Double = 0 {
1515 didSet {
1616 value = min(maximumValue, max(minimumValue, value))
17− label.text = String(value)
17+
18+ let isInteger = floor(value) == value
19+
20+ if showIntegerIfDoubleIsInteger && isInteger {
21+ label.text = String(stringInterpolationSegment: Int(value))
22+ } else {
23+ label.text = String(stringInterpolationSegment: value)
24+ }
1825
1926 if oldValue != value {
2027 sendActionsForControlEvents(.ValueChanged)
@@ -23,22 +30,27 @@ import UIKit
2330 }
2431
2532 /// Minimum value. Must be less than maximumValue. Defaults to 0.
26− @IBInspectable public var minimumValue: Int = 0 {
33+ @IBInspectable public var minimumValue: Double = 0 {
2734 didSet {
2835 value = min(maximumValue, max(minimumValue, value))
2936 }
3037 }
3138
32− /// Maximum value. Must be more than minimumValue. Defaults to 10.
33− @IBInspectable public var maximumValue: Int = 10 {
39+ /// Maximum value. Must be more than minimumValue. Defaults to 100.
40+ @IBInspectable public var maximumValue: Double = 100 {
3441 didSet {
3542 value = min(maximumValue, max(minimumValue, value))
3643 }
3744 }
3845
46+ /// Step/Increment value as in UIStepper. Defaults to 1.
47+ @IBInspectable public var stepValue: Double = 1
48+
3949 /// The same as UIStepper's autorepeat. If true, holding on the buttons or keeping the pan gesture alters the value repeatedly. Defaults to true.
4050 @IBInspectable public var autorepeat: Bool = true
4151
52+ @IBInspectable public var showIntegerIfDoubleIsInteger: Bool = true
53+
4254 /// Text on the left button. Be sure that it fits in the button. Defaults to "-".
4355 @IBInspectable public var leftButtonText: String = "-" {
4456 didSet {
@@ -159,7 +171,11 @@ import UIKit
159171 lazy var label: UILabel = {
160172 let label = UILabel()
161173 label.textAlignment = .Center
162− label.text = String(self.value)
174+ if self.showIntegerIfDoubleIsInteger && floor(self.value) == self.value {
175+ label.text = String(stringInterpolationSegment: Int(self.value))
176+ } else {
177+ label.text = String(stringInterpolationSegment: self.value)
178+ }
163179 label.textColor = self.labelTextColor
164180 label.backgroundColor = self.labelBackgroundColor
165181 label.font = self.labelFont
@@ -264,9 +280,9 @@ import UIKit
264280
265281 func updateValue() {
266282 if stepperState == .ShouldIncrease {
267− value += 1
283+ value += stepValue
268284 } else if stepperState == .ShouldDecrease {
269− value -= 1
285+ value -= stepValue
270286 }
271287 }
272288}