on master help sign in
Add API
commit3a236901203d9aea852ece3b5ffbf5ceb06d395c authorGunay Mert Karadogan <mertkaradogan@gmail.com> dateWed 1 Jul 2015, 17:24 (11 years ago) parent3978cf7
1 file changed+31−12
GMStepper/GMStepper/GMStepper.swift+31−12
GMStepper/GMStepper/GMStepper.swift+31−12
@@ -17,9 +17,22 @@ public class GMStepper: UIView {
1717 }
1818
1919 public var minimumValue = 0
20−
2120 public var maximumValue = 10
2221
22+ public var leftButtonText = "-"
23+ public var rightButtonText = "+"
24+
25+ public var buttonsTextColor = UIColor(red:0.93, green:0.94, blue:0.95, alpha:1)
26+
27+ public var buttonsBackgroundColor = UIColor(red:0.21, green:0.5, blue:0.74, alpha:1)
28+
29+ public var buttonsFont = UIFont(name: "AvenirNext-Bold", size: 20.0)!
30+
31+ public var labelTextColor = UIColor(red:0.93, green:0.94, blue:0.95, alpha:1)
32+
33+ public var labelBackgroundColor = UIColor(red:0.26, green:0.6, blue:0.87, alpha:1)
34+
35+ public var labelFont = UIFont(name: "AvenirNext-Bold", size: 25.0)!
2336
2437 private let leftButton = UIButton()
2538 private let rightButton = UIButton()
@@ -28,23 +41,29 @@ public class GMStepper: UIView {
2841 required public init(coder aDecoder: NSCoder) {
2942 super.init(coder: aDecoder)
3043
31− leftButton.setTitle("-", forState: [.Normal])
32− rightButton.setTitle("+", forState: [.Normal])
33−
44+ leftButton.setTitle(leftButtonText, forState: [.Normal])
45+ leftButton.setTitleColor(buttonsTextColor, forState: [.Normal])
46+ leftButton.backgroundColor = buttonsBackgroundColor
47+ leftButton.titleLabel?.font = buttonsFont
3448 leftButton.addTarget(self, action: "leftButtonTapped:", forControlEvents: .TouchDown)
49+ addSubview(leftButton)
50+
51+ rightButton.setTitle(rightButtonText, forState: [.Normal])
52+ rightButton.setTitleColor(buttonsTextColor, forState: [.Normal])
53+ rightButton.backgroundColor = buttonsBackgroundColor
54+ rightButton.titleLabel?.font = buttonsFont
3555 rightButton.addTarget(self, action: "rightButtonTapped:", forControlEvents: .TouchDown)
56+ addSubview(rightButton)
3657
3758 label.textAlignment = .Center
3859 label.text = String(value)
39−
40− addSubview(leftButton)
41− addSubview(rightButton)
60+ label.textColor = labelTextColor
61+ label.backgroundColor = labelBackgroundColor
62+ label.font = labelFont
4263 addSubview(label)
4364
4465 backgroundColor = UIColor.grayColor()
45− label.backgroundColor = UIColor.redColor()
46− leftButton.backgroundColor = UIColor.purpleColor()
47− rightButton.backgroundColor = UIColor.purpleColor()
66+
4867 }
4968
5069 public override func layoutSubviews() {
@@ -56,11 +75,11 @@ public class GMStepper: UIView {
5675 rightButton.frame = CGRect(x: labelWidth + buttonWidth, y: 0, width: buttonWidth, height: bounds.size.height)
5776 }
5877
59− private func leftButtonTapped(button: UIButton) {
78+ @objc private func leftButtonTapped(button: UIButton) {
6079 value -= 1
6180 }
6281
63− private func rightButtonTapped(button: UIButton) {
82+ @objc private func rightButtonTapped(button: UIButton) {
6483 value += 1
6584 }
6685}