on master help sign in
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

commitbc199530cbf9a7d6c23bf4d3bdfa4309efc2deed authorLuu Gia Thuy <luugiathuy@gmail.com> dateThu 21 Apr 2016, 18:24 (10 years ago) parentb7acb5d
2 files changed+60−9
GMStepper/GMStepper.swift+16 GMStepperExample/GMStepperExample/Base.lproj/Main.storyboard+44−9
GMStepper/GMStepper.swift+16
@@ -122,6 +122,22 @@ import UIKit
122122 clipsToBounds = true
123123 }
124124 }
125+
126+ /// Border width of the stepper and middle label's layer. Defaults to 0.0.
127+ @IBInspectable public var borderWidth: CGFloat = 0.0 {
128+ didSet {
129+ layer.borderWidth = borderWidth
130+ label.layer.borderWidth = borderWidth
131+ }
132+ }
133+
134+ /// Color of the border of the stepper and middle label's layer. Defaults to clear color.
135+ @IBInspectable public var borderColor: UIColor = UIColor.clearColor() {
136+ didSet {
137+ layer.borderColor = borderColor.CGColor
138+ label.layer.borderColor = borderColor.CGColor
139+ }
140+ }
125141
126142 /// 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.
127143 @IBInspectable public var labelWidthWeight: CGFloat = 0.5 {
GMStepperExample/GMStepperExample/Base.lproj/Main.storyboard+44−9
@@ -1,8 +1,8 @@
11<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2−<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="15A279b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
2+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
33 <dependencies>
44 <deployment identifier="iOS"/>
5− <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
5+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
66 <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
77 </dependencies>
88 <scenes>
@@ -19,8 +19,7 @@
1919 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2020 <subviews>
2121 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="AU6-4C-B2F" customClass="GMStepper" customModule="GMStepperExample" customModuleProvider="target">
22− <rect key="frame" x="24" y="28" width="552" height="44"/>
23− <animations/>
22+ <rect key="frame" x="28" y="28" width="544" height="44"/>
2423 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
2524 <constraints>
2625 <constraint firstAttribute="height" constant="44" id="6mC-hP-wFD"/>
@@ -36,7 +35,6 @@
3635 </view>
3736 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="if7-U5-bAM" customClass="GMStepper" customModule="GMStepperExample" customModuleProvider="target">
3837 <rect key="frame" x="140" y="116" width="320" height="66"/>
39− <animations/>
4038 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
4139 <constraints>
4240 <constraint firstAttribute="height" constant="66" id="iQi-6P-vt9"/>
@@ -65,7 +63,6 @@
6563 </view>
6664 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="R9n-I0-fq7" customClass="GMStepper" customModule="GMStepperExample" customModuleProvider="target">
6765 <rect key="frame" x="200" y="226" width="200" height="66"/>
68− <animations/>
6966 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
7067 <constraints>
7168 <constraint firstAttribute="width" constant="200" id="dVu-w0-mf0"/>
@@ -90,8 +87,7 @@
9087 </userDefinedRuntimeAttributes>
9188 </view>
9289 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U8X-8Z-7Mo" customClass="GMStepper" customModule="GMStepperExample" customModuleProvider="target">
93− <rect key="frame" x="24" y="336" width="552" height="44"/>
94− <animations/>
90+ <rect key="frame" x="28" y="336" width="544" height="44"/>
9591 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
9692 <constraints>
9793 <constraint firstAttribute="height" constant="44" id="aF3-T7-dIP"/>
@@ -131,8 +127,44 @@
131127 </mask>
132128 </variation>
133129 </view>
130+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9Ri-Yr-sRs" customClass="GMStepper" customModule="GMStepperExample" customModuleProvider="target">
131+ <rect key="frame" x="210" y="424" width="180" height="50"/>
132+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
133+ <constraints>
134+ <constraint firstAttribute="width" constant="180" id="dhO-Nd-SFk"/>
135+ <constraint firstAttribute="height" constant="50" id="xPS-vU-cZc"/>
136+ </constraints>
137+ <userDefinedRuntimeAttributes>
138+ <userDefinedRuntimeAttribute type="number" keyPath="maximumValue">
139+ <real key="value" value="10"/>
140+ </userDefinedRuntimeAttribute>
141+ <userDefinedRuntimeAttribute type="number" keyPath="stepValue">
142+ <real key="value" value="1"/>
143+ </userDefinedRuntimeAttribute>
144+ <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
145+ <real key="value" value="2"/>
146+ </userDefinedRuntimeAttribute>
147+ <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
148+ <real key="value" value="4"/>
149+ </userDefinedRuntimeAttribute>
150+ <userDefinedRuntimeAttribute type="color" keyPath="buttonsBackgroundColor">
151+ <color key="value" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
152+ </userDefinedRuntimeAttribute>
153+ <userDefinedRuntimeAttribute type="color" keyPath="buttonsTextColor">
154+ <color key="value" red="1" green="0.47058823529999999" blue="0.15686274510000001" alpha="1" colorSpace="calibratedRGB"/>
155+ </userDefinedRuntimeAttribute>
156+ <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
157+ <color key="value" red="1" green="0.47058823529999999" blue="0.15686274510000001" alpha="1" colorSpace="calibratedRGB"/>
158+ </userDefinedRuntimeAttribute>
159+ <userDefinedRuntimeAttribute type="color" keyPath="labelBackgroundColor">
160+ <color key="value" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
161+ </userDefinedRuntimeAttribute>
162+ <userDefinedRuntimeAttribute type="color" keyPath="labelTextColor">
163+ <color key="value" red="1" green="0.47058823529999999" blue="0.15686274510000001" alpha="1" colorSpace="calibratedRGB"/>
164+ </userDefinedRuntimeAttribute>
165+ </userDefinedRuntimeAttributes>
166+ </view>
134167 </subviews>
135− <animations/>
136168 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
137169 <constraints>
138170 <constraint firstItem="R9n-I0-fq7" firstAttribute="centerX" secondItem="U8X-8Z-7Mo" secondAttribute="centerX" id="3cD-WW-Qg4"/>
@@ -143,7 +175,9 @@
143175 <constraint firstItem="if7-U5-bAM" firstAttribute="centerX" secondItem="R9n-I0-fq7" secondAttribute="centerX" id="K7g-rC-ehJ"/>
144176 <constraint firstItem="U8X-8Z-7Mo" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" constant="8" id="S1b-pD-UXA"/>
145177 <constraint firstItem="U8X-8Z-7Mo" firstAttribute="top" secondItem="R9n-I0-fq7" secondAttribute="bottom" constant="44" id="fBW-Xx-pa0"/>
178+ <constraint firstItem="9Ri-Yr-sRs" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="fay-qT-jKR"/>
146179 <constraint firstItem="AU6-4C-B2F" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" constant="8" id="iIM-b2-jzV"/>
180+ <constraint firstItem="9Ri-Yr-sRs" firstAttribute="top" secondItem="U8X-8Z-7Mo" secondAttribute="bottom" constant="44" id="nKi-Fp-8B7"/>
147181 <constraint firstAttribute="trailingMargin" secondItem="U8X-8Z-7Mo" secondAttribute="trailing" constant="8" id="ppd-nb-fL8"/>
148182 <constraint firstItem="AU6-4C-B2F" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="8" symbolic="YES" id="zDK-gF-kms"/>
149183 </constraints>
@@ -154,6 +188,7 @@
154188 </viewController>
155189 <placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
156190 </objects>
191+ <point key="canvasLocation" x="274" y="363"/>
157192 </scene>
158193 </scenes>
159194</document>