@@ -8,7 +8,7 @@
9import UIKit
9import UIKit
11−public class GMStepper: UIControl {
11+@IBDesignable public class GMStepper: UIControl {
12 public var value = 0 {
12 public var value = 0 {
14 value = min(maximumValue, max(minimumValue, value))
14 value = min(maximumValue, max(minimumValue, value))
@@ -20,23 +20,71 @@ public class GMStepper: UIControl {
23− public var minimumValue = 0
23+ @IBInspectable public var minimumValue: Int = 0 {
24− public var maximumValue = 10
24+ didSet {
26− public var leftButtonText = "-"
29+ @IBInspectable public var maximumValue: Int = 10 {
27− public var rightButtonText = "+"
30+ didSet {
29− public var buttonsTextColor = UIColor.whiteColor()
35+ @IBInspectable public var leftButtonText: String = "-" {
37+ leftButton.setTitle(leftButtonText, forState: [.Normal])
41+ @IBInspectable public var rightButtonText: String = "+" {
43+ rightButton.setTitle(rightButtonText, forState: [.Normal])
47+ @IBInspectable public var buttonsTextColor: UIColor = UIColor.whiteColor() {
49+ for button in [leftButton, rightButton] {
50+ button.setTitleColor(buttonsTextColor, forState: [.Normal])
31− public var buttonsBackgroundColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1)
55+ @IBInspectable public var buttonsBackgroundColor: UIColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1) {
57+ for button in [leftButton, rightButton] {
58+ button.backgroundColor = buttonsBackgroundColor
33− public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)!
63+ public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)! {
65+ for button in [leftButton, rightButton] {
66+ button.titleLabel?.font = buttonsFont
35− public var labelTextColor = UIColor.whiteColor()
71+ @IBInspectable public var labelTextColor: UIColor = UIColor.whiteColor() {
73+ label.textColor = labelTextColor
37− public var labelBackgroundColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
77+ @IBInspectable public var labelBackgroundColor: UIColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1) {
79+ label.backgroundColor = labelBackgroundColor
39− public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)!
83+ public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)! {
85+ label.font = labelFont
41 private let leftButton = UIButton()
89 private let leftButton = UIButton()
42 private let rightButton = UIButton()
90 private let rightButton = UIButton()
@@ -44,7 +92,15 @@ public class GMStepper: UIControl {
45 required public init(coder aDecoder: NSCoder) {
93 required public init(coder aDecoder: NSCoder) {
46 super.init(coder: aDecoder)
94 super.init(coder: aDecoder)
98+ public override init(frame: CGRect) {
99+ super.init(frame: frame)
103+ private func setup() {
48 leftButton.setTitle(leftButtonText, forState: [.Normal])
104 leftButton.setTitle(leftButtonText, forState: [.Normal])
49 leftButton.setTitleColor(buttonsTextColor, forState: [.Normal])
105 leftButton.setTitleColor(buttonsTextColor, forState: [.Normal])
50 leftButton.backgroundColor = buttonsBackgroundColor
106 leftButton.backgroundColor = buttonsBackgroundColor
@@ -65,9 +121,6 @@ public class GMStepper: UIControl {
65 label.backgroundColor = labelBackgroundColor
121 label.backgroundColor = labelBackgroundColor
66 label.font = labelFont
122 label.font = labelFont
67 addSubview(label)
123 addSubview(label)
69− backgroundColor = UIColor.grayColor()
73 public override func layoutSubviews() {
126 public override func layoutSubviews() {