@@ -9,6 +9,8 @@
99import UIKit
1010
1111@IBDesignable public class GMStepper: UIControl {
12+
13+ /// Current value of the stepper. Defaults to 0.
1214 public var value = 0 {
1315 didSet {
1416 value = min(maximumValue, max(minimumValue, value))
@@ -20,30 +22,35 @@ import UIKit
2022 }
2123 }
2224
25+ /// Minimum value. Must be less than maximumValue. Defaults to 0.
2326 @IBInspectable public var minimumValue: Int = 0 {
2427 didSet {
2528 value = 0
2629 }
2730 }
2831
32+ /// Maximum value. Must be more than minimumValue. Defaults to 10.
2933 @IBInspectable public var maximumValue: Int = 10 {
3034 didSet {
3135 value = 0
3236 }
3337 }
3438
39+ /// Text on the left button. Be sure that it fits in the button. Defaults to "-".
3540 @IBInspectable public var leftButtonText: String = "-" {
3641 didSet {
3742 leftButton.setTitle(leftButtonText, forState: .Normal)
3843 }
3944 }
4045
46+ /// Text on the right button. Be sure that it fits in the button. Defaults to "+".
4147 @IBInspectable public var rightButtonText: String = "+" {
4248 didSet {
4349 rightButton.setTitle(rightButtonText, forState: .Normal)
4450 }
4551 }
4652
53+ /// Text color of the buttons. Defaults to white.
4754 @IBInspectable public var buttonsTextColor: UIColor = UIColor.whiteColor() {
4855 didSet {
4956 for button in [leftButton, rightButton] {
@@ -52,6 +59,7 @@ import UIKit
5259 }
5360 }
5461
62+ /// Background color of the buttons. Defaults to dark blue.
5563 @IBInspectable public var buttonsBackgroundColor: UIColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1) {
5664 didSet {
5765 for button in [leftButton, rightButton] {
@@ -61,6 +69,7 @@ import UIKit
6169 }
6270 }
6371
72+ /// Font of the buttons. Defaults to AvenirNext-Bold, 20.0 points in size.
6473 public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)! {
6574 didSet {
6675 for button in [leftButton, rightButton] {
@@ -69,24 +78,28 @@ import UIKit
6978 }
7079 }
7180
81+ /// Text color of the middle label. Defaults to white.
7282 @IBInspectable public var labelTextColor: UIColor = UIColor.whiteColor() {
7383 didSet {
7484 label.textColor = labelTextColor
7585 }
7686 }
7787
88+ /// Text color of the middle label. Defaults to lighter blue.
7889 @IBInspectable public var labelBackgroundColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1) {
7990 didSet {
8091 label.backgroundColor = labelBackgroundColor
8192 }
8293 }
8394
95+ /// Font of the middle label. Defaults to AvenirNext-Bold, 25.0 points in size.
8496 public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)! {
8597 didSet {
8698 label.font = labelFont
8799 }
88100 }
89101
102+ /// Corner radius of the stepper's layer. Defaults to 4.0.
90103 @IBInspectable public var cornerRadius: CGFloat = 4.0 {
91104 didSet {
92105 layer.cornerRadius = cornerRadius
@@ -94,6 +107,7 @@ import UIKit
94107 }
95108 }
96109
110+ /// Percentage of the middle label's width. Must be between 0 and 1. Defaults to 0.5. Be sure that it is wide enough to show the value.
97111 @IBInspectable public var labelWidthWeight: CGFloat = 0.5 {
98112 didSet {
99113 labelWidthWeight = min(1, max(0, labelWidthWeight))
@@ -101,10 +115,18 @@ import UIKit
101115 }
102116 }
103117
118+ /**
119+ Width of the sliding animation. When buttons clicked, the middle label does a slide animation towards to the clicked button. Defaults to 5.
120+ */
104121 private let labelSlideLength: CGFloat = 5
122+
123+ /// Duration of the sliding animation
105124 private let labelSlideDuration: NSTimeInterval = 0.1
106125
126+ /// Duration of the flashing animation when the value hits the limit.
107127 private let limitHitAnimationDuration: NSTimeInterval = 0.1
128+
129+ /// Color of the flashing animation on the buttons in case the value hit the limit.
108130 @IBInspectable public var limitHitAnimationColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
109131
110132 private let leftButton = UIButton()