@@ -96,6 +96,9 @@ import UIKit
9696 private let labelSlideLength: CGFloat = 5
9797 private let labelSlideDuration: NSTimeInterval = 0.1
9898
99+ private let limitHitAnimationDuration: NSTimeInterval = 0.1
100+ @IBInspectable public var limitHitAnimationColor: UIColor = UIColor(red:0.23, green:0.3, blue:0.51, alpha:1)
101+
99102 private let leftButton = UIButton()
100103 private let rightButton = UIButton()
101104 private let label = UILabel()
@@ -147,19 +150,27 @@ import UIKit
147150 }
148151
149152 @objc private func leftButtonTapped(button: UIButton) {
150− value -= 1
151− animateSlideLeft()
153+ if value == minimumValue {
154+ animateLimitHitForButton(leftButton)
155+ } else {
156+ value -= 1
157+ animateSlideLeft()
158+ }
152159 }
153160
154161 @objc private func rightButtonTapped(button: UIButton) {
155− value += 1
156− animateSlideRight()
162+ if value == maximumValue {
163+ animateLimitHitForButton(rightButton)
164+ } else {
165+ value += 1
166+ animateSlideRight()
167+ }
157168 }
158169
159170 private func animateSlideLeft() {
160171 UIView.animateWithDuration(labelSlideDuration, animations: {
161172 self.label.center.x -= self.labelSlideLength
162− }, completion : { _ in
173+ }, completion: { _ in
163174 UIView.animateWithDuration(self.labelSlideDuration, animations: {
164175 self.label.center.x += self.labelSlideLength
165176 })
@@ -169,10 +180,18 @@ import UIKit
169180 private func animateSlideRight() {
170181 UIView.animateWithDuration(labelSlideDuration, animations: {
171182 self.label.center.x += self.labelSlideLength
172− }, completion : { _ in
183+ }, completion: { _ in
173184 UIView.animateWithDuration(self.labelSlideDuration, animations: {
174185 self.label.center.x -= self.labelSlideLength
175186 })
176187 })
177188 }
189+
190+ private func animateLimitHitForButton(button: UIButton){
191+ UIView.animateWithDuration(limitHitAnimationDuration, animations: {
192+ button.backgroundColor = self.limitHitAnimationColor
193+ }, completion: { _ in
194+ button.backgroundColor = self.buttonsBackgroundColor
195+ })
196+ }
178197}