on master help sign in
Add labelWidthWeight. Closes #6
cdaf072Gunay Mert Karadogan
GMStepper/GMStepper/GMStepper.swift+9−2
@@ -94,6 +94,13 @@ import UIKit
94 }
94 }
95 }
95 }
96
96
97+ @IBInspectable public var labelWidthWeight: CGFloat = 0.5 {
98+ didSet {
99+ labelWidthWeight = min(1, max(0, labelWidthWeight))
100+ setNeedsLayout()
101+ }
102+ }
103+
97 private let labelSlideLength: CGFloat = 5
104 private let labelSlideLength: CGFloat = 5
98 private let labelSlideDuration: NSTimeInterval = 0.1
105 private let labelSlideDuration: NSTimeInterval = 0.1
99
106
@@ -142,8 +149,8 @@ import UIKit
142 }
149 }
143
150
144 public override func layoutSubviews() {
151 public override func layoutSubviews() {
145− let buttonWidth = bounds.size.width * 0.25
152+ let buttonWidth = bounds.size.width * ((1 - labelWidthWeight) / 2)
146− let labelWidth = bounds.size.width * 0.5
153+ let labelWidth = bounds.size.width * labelWidthWeight
147
154
148 leftButton.frame = CGRect(x: 0, y: 0, width: buttonWidth, height: bounds.size.height)
155 leftButton.frame = CGRect(x: 0, y: 0, width: buttonWidth, height: bounds.size.height)
149 label.frame = CGRect(x: buttonWidth, y: 0, width: labelWidth, height: bounds.size.height)
156 label.frame = CGRect(x: buttonWidth, y: 0, width: labelWidth, height: bounds.size.height)