on master help sign in
Add docs
10aff6cGunay Mert Karadogan
GMStepper.podspec+1−1
@@ -1,6 +1,6 @@
1Pod::Spec.new do |s|
1Pod::Spec.new do |s|
2 s.name = "GMStepper"
2 s.name = "GMStepper"
3− s.version = "0.1.0"
3+ s.version = "0.1.1"
4 s.summary = "A stepper with a sliding label in the middle."
4 s.summary = "A stepper with a sliding label in the middle."
5 s.homepage = "https://github.com/gmertk/GMStepper"
5 s.homepage = "https://github.com/gmertk/GMStepper"
6 s.screenshots = "https://dl.dropboxusercontent.com/u/4397140/pod-screenshots/screenshot_1.png"
6 s.screenshots = "https://dl.dropboxusercontent.com/u/4397140/pod-screenshots/screenshot_1.png"
GMStepper/GMStepper.swift+22
@@ -9,6 +9,8 @@
9import UIKit
9import UIKit
10
10
11@IBDesignable public class GMStepper: UIControl {
11@IBDesignable public class GMStepper: UIControl {
12+
13+ /// Current value of the stepper. Defaults to 0.
12 public var value = 0 {
14 public var value = 0 {
13 didSet {
15 didSet {
14 value = min(maximumValue, max(minimumValue, value))
16 value = min(maximumValue, max(minimumValue, value))
@@ -20,30 +22,35 @@ import UIKit
20 }
22 }
21 }
23 }
22
24
25+ /// Minimum value. Must be less than maximumValue. Defaults to 0.
23 @IBInspectable public var minimumValue: Int = 0 {
26 @IBInspectable public var minimumValue: Int = 0 {
24 didSet {
27 didSet {
25 value = 0
28 value = 0
26 }
29 }
27 }
30 }
28
31
32+ /// Maximum value. Must be more than minimumValue. Defaults to 10.
29 @IBInspectable public var maximumValue: Int = 10 {
33 @IBInspectable public var maximumValue: Int = 10 {
30 didSet {
34 didSet {
31 value = 0
35 value = 0
32 }
36 }
33 }
37 }
34
38
39+ /// Text on the left button. Be sure that it fits in the button. Defaults to "-".
35 @IBInspectable public var leftButtonText: String = "-" {
40 @IBInspectable public var leftButtonText: String = "-" {
36 didSet {
41 didSet {
37 leftButton.setTitle(leftButtonText, forState: .Normal)
42 leftButton.setTitle(leftButtonText, forState: .Normal)
38 }
43 }
39 }
44 }
40
45
46+ /// Text on the right button. Be sure that it fits in the button. Defaults to "+".
41 @IBInspectable public var rightButtonText: String = "+" {
47 @IBInspectable public var rightButtonText: String = "+" {
42 didSet {
48 didSet {
43 rightButton.setTitle(rightButtonText, forState: .Normal)
49 rightButton.setTitle(rightButtonText, forState: .Normal)
44 }
50 }
45 }
51 }
46
52
53+ /// Text color of the buttons. Defaults to white.
47 @IBInspectable public var buttonsTextColor: UIColor = UIColor.whiteColor() {
54 @IBInspectable public var buttonsTextColor: UIColor = UIColor.whiteColor() {
48 didSet {
55 didSet {
49 for button in [leftButton, rightButton] {
56 for button in [leftButton, rightButton] {
@@ -52,6 +59,7 @@ import UIKit
52 }
59 }
53 }
60 }
54
61
62+ /// Background color of the buttons. Defaults to dark blue.
55 @IBInspectable public var buttonsBackgroundColor: UIColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1) {
63 @IBInspectable public var buttonsBackgroundColor: UIColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1) {
56 didSet {
64 didSet {
57 for button in [leftButton, rightButton] {
65 for button in [leftButton, rightButton] {
@@ -61,6 +69,7 @@ import UIKit
61 }
69 }
62 }
70 }
63
71
72+ /// Font of the buttons. Defaults to AvenirNext-Bold, 20.0 points in size.
64 public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)! {
73 public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)! {
65 didSet {
74 didSet {
66 for button in [leftButton, rightButton] {
75 for button in [leftButton, rightButton] {
@@ -69,24 +78,28 @@ import UIKit
69 }
78 }
70 }
79 }
71
80
81+ /// Text color of the middle label. Defaults to white.
72 @IBInspectable public var labelTextColor: UIColor = UIColor.whiteColor() {
82 @IBInspectable public var labelTextColor: UIColor = UIColor.whiteColor() {
73 didSet {
83 didSet {
74 label.textColor = labelTextColor
84 label.textColor = labelTextColor
75 }
85 }
76 }
86 }
77
87
88+ /// Text color of the middle label. Defaults to lighter blue.
78 @IBInspectable public var labelBackgroundColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1) {
89 @IBInspectable public var labelBackgroundColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1) {
79 didSet {
90 didSet {
80 label.backgroundColor = labelBackgroundColor
91 label.backgroundColor = labelBackgroundColor
81 }
92 }
82 }
93 }
83
94
95+ /// Font of the middle label. Defaults to AvenirNext-Bold, 25.0 points in size.
84 public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)! {
96 public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)! {
85 didSet {
97 didSet {
86 label.font = labelFont
98 label.font = labelFont
87 }
99 }
88 }
100 }
89
101
102+ /// Corner radius of the stepper's layer. Defaults to 4.0.
90 @IBInspectable public var cornerRadius: CGFloat = 4.0 {
103 @IBInspectable public var cornerRadius: CGFloat = 4.0 {
91 didSet {
104 didSet {
92 layer.cornerRadius = cornerRadius
105 layer.cornerRadius = cornerRadius
@@ -94,6 +107,7 @@ import UIKit
94 }
107 }
95 }
108 }
96
109
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.
97 @IBInspectable public var labelWidthWeight: CGFloat = 0.5 {
111 @IBInspectable public var labelWidthWeight: CGFloat = 0.5 {
98 didSet {
112 didSet {
99 labelWidthWeight = min(1, max(0, labelWidthWeight))
113 labelWidthWeight = min(1, max(0, labelWidthWeight))
@@ -101,10 +115,18 @@ import UIKit
101 }
115 }
102 }
116 }
103
117
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+ */
104 private let labelSlideLength: CGFloat = 5
121 private let labelSlideLength: CGFloat = 5
122+
123+ /// Duration of the sliding animation
105 private let labelSlideDuration: NSTimeInterval = 0.1
124 private let labelSlideDuration: NSTimeInterval = 0.1
106
125
126+ /// Duration of the flashing animation when the value hits the limit.
107 private let limitHitAnimationDuration: NSTimeInterval = 0.1
127 private let limitHitAnimationDuration: NSTimeInterval = 0.1
128+
129+ /// Color of the flashing animation on the buttons in case the value hit the limit.
108 @IBInspectable public var limitHitAnimationColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
130 @IBInspectable public var limitHitAnimationColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
109
131
110 private let leftButton = UIButton()
132 private let leftButton = UIButton()