From bc199530cbf9a7d6c23bf4d3bdfa4309efc2deed Mon Sep 17 00:00:00 2001 From: Luu Gia Thuy Date: Thu, 21 Apr 2016 18:24:21 +0800 Subject: [PATCH] Add borderWidth and borderColor properties This will help creating steppers with transparent background colors, borders and separators between buttons and middle label (similar to default iOS style --- GMStepper/GMStepper.swift | 16 ++++++ .../Base.lproj/Main.storyboard | 53 +++++++++++++++---- 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/GMStepper/GMStepper.swift b/GMStepper/GMStepper.swift index da5a252..efef1f4 100644 --- a/GMStepper/GMStepper.swift +++ b/GMStepper/GMStepper.swift @@ -122,6 +122,22 @@ import UIKit clipsToBounds = true } } + + /// Border width of the stepper and middle label's layer. Defaults to 0.0. + @IBInspectable public var borderWidth: CGFloat = 0.0 { + didSet { + layer.borderWidth = borderWidth + label.layer.borderWidth = borderWidth + } + } + + /// Color of the border of the stepper and middle label's layer. Defaults to clear color. + @IBInspectable public var borderColor: UIColor = UIColor.clearColor() { + didSet { + layer.borderColor = borderColor.CGColor + label.layer.borderColor = borderColor.CGColor + } + } /// Percentage of the middle label's width. Must be between 0 and 1. Defaults to 0.5. Be sure that it is wide enough to show the value. @IBInspectable public var labelWidthWeight: CGFloat = 0.5 { diff --git a/GMStepperExample/GMStepperExample/Base.lproj/Main.storyboard b/GMStepperExample/GMStepperExample/Base.lproj/Main.storyboard index bf995ae..7c31024 100644 --- a/GMStepperExample/GMStepperExample/Base.lproj/Main.storyboard +++ b/GMStepperExample/GMStepperExample/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -19,8 +19,7 @@ - - + @@ -36,7 +35,6 @@ - @@ -65,7 +63,6 @@ - @@ -90,8 +87,7 @@ - - + @@ -131,8 +127,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -143,7 +175,9 @@ + + @@ -154,6 +188,7 @@ +