@@ -17,9 +17,22 @@ public class GMStepper: UIView {
19 public var minimumValue = 0
19 public var minimumValue = 0
21 public var maximumValue = 10
20 public var maximumValue = 10
22+ public var leftButtonText = "-"
23+ public var rightButtonText = "+"
25+ public var buttonsTextColor = UIColor(red:0.93, green:0.94, blue:0.95, alpha:1)
27+ public var buttonsBackgroundColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1)
29+ public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)!
31+ public var labelTextColor = UIColor(red:0.93, green:0.94, blue:0.95, alpha:1)
33+ public var labelBackgroundColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
35+ public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)!
24 private let leftButton = UIButton()
37 private let leftButton = UIButton()
25 private let rightButton = UIButton()
38 private let rightButton = UIButton()
@@ -28,23 +41,29 @@ public class GMStepper: UIView {
28 required public init(coder aDecoder: NSCoder) {
41 required public init(coder aDecoder: NSCoder) {
29 super.init(coder: aDecoder)
42 super.init(coder: aDecoder)
31− leftButton.setTitle("-", forState: [.Normal])
44+ leftButton.setTitle(leftButtonText, forState: [.Normal])
32− rightButton.setTitle("+", forState: [.Normal])
45+ leftButton.setTitleColor(buttonsTextColor, forState: [.Normal])
33−
46+ leftButton.backgroundColor = buttonsBackgroundColor
47+ leftButton.titleLabel?.font = buttonsFont
34 leftButton.addTarget(self, action: "leftButtonTapped:", forControlEvents: .TouchDown)
48 leftButton.addTarget(self, action: "leftButtonTapped:", forControlEvents: .TouchDown)
49+ addSubview(leftButton)
51+ rightButton.setTitle(rightButtonText, forState: [.Normal])
52+ rightButton.setTitleColor(buttonsTextColor, forState: [.Normal])
53+ rightButton.backgroundColor = buttonsBackgroundColor
54+ rightButton.titleLabel?.font = buttonsFont
35 rightButton.addTarget(self, action: "rightButtonTapped:", forControlEvents: .TouchDown)
55 rightButton.addTarget(self, action: "rightButtonTapped:", forControlEvents: .TouchDown)
56+ addSubview(rightButton)
37 label.textAlignment = .Center
58 label.textAlignment = .Center
38 label.text = String(value)
59 label.text = String(value)
39−
60+ label.textColor = labelTextColor
40− addSubview(leftButton)
61+ label.backgroundColor = labelBackgroundColor
41− addSubview(rightButton)
62+ label.font = labelFont
42 addSubview(label)
63 addSubview(label)
44 backgroundColor = UIColor.grayColor()
65 backgroundColor = UIColor.grayColor()
45− label.backgroundColor = UIColor.redColor()
66+
46− leftButton.backgroundColor = UIColor.purpleColor()
47− rightButton.backgroundColor = UIColor.purpleColor()
50 public override func layoutSubviews() {
69 public override func layoutSubviews() {
@@ -56,11 +75,11 @@ public class GMStepper: UIView {
56 rightButton.frame = CGRect(x: labelWidth + buttonWidth, y: 0, width: buttonWidth, height: bounds.size.height)
75 rightButton.frame = CGRect(x: labelWidth + buttonWidth, y: 0, width: buttonWidth, height: bounds.size.height)
59− private func leftButtonTapped(button: UIButton) {
78+ @objc private func leftButtonTapped(button: UIButton) {
60 value -= 1
79 value -= 1
63− private func rightButtonTapped(button: UIButton) {
82+ @objc private func rightButtonTapped(button: UIButton) {
64 value += 1
83 value += 1