Skip to content

Commit a4844a3

Browse files
committed
Add Verification Code Programatically example
1 parent dda524d commit a4844a3

3 files changed

Lines changed: 104 additions & 2 deletions

File tree

Example/KWVerificationCodeView.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1616
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
1717
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
18+
D1AA5A4D20D0FD7B007FE474 /* ProgramaticalVerificationCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1AA5A4C20D0FD7B007FE474 /* ProgramaticalVerificationCodeViewController.swift */; };
1819
/* End PBXBuildFile section */
1920

2021
/* Begin PBXContainerItemProxy section */
@@ -44,6 +45,7 @@
4445
8F723ADDC751FC9CC3C9BE34 /* Pods-KWVerificationCodeView_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KWVerificationCodeView_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-KWVerificationCodeView_Tests/Pods-KWVerificationCodeView_Tests.release.xcconfig"; sourceTree = "<group>"; };
4546
C3C8FC4284D4530532E3C9FB /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
4647
C68BD3F967305D340EA20FFD /* Pods_KWVerificationCodeView_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_KWVerificationCodeView_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
48+
D1AA5A4C20D0FD7B007FE474 /* ProgramaticalVerificationCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgramaticalVerificationCodeViewController.swift; sourceTree = "<group>"; };
4749
D51BF4885572F8FECD1E4AF7 /* Pods-KWVerificationCodeView_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-KWVerificationCodeView_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example.debug.xcconfig"; sourceTree = "<group>"; };
4850
E6C0C121AF93D56E0FE9F947 /* KWVerificationCodeView.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = KWVerificationCodeView.podspec; path = ../KWVerificationCodeView.podspec; sourceTree = "<group>"; };
4951
F538A5E79FE77B8D323F9B7B /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
@@ -106,6 +108,7 @@
106108
children = (
107109
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
108110
607FACD71AFB9204008FA782 /* VerificationCodeViewController.swift */,
111+
D1AA5A4C20D0FD7B007FE474 /* ProgramaticalVerificationCodeViewController.swift */,
109112
607FACD91AFB9204008FA782 /* Main.storyboard */,
110113
607FACDC1AFB9204008FA782 /* Images.xcassets */,
111114
607FACDE1AFB9204008FA782 /* LaunchScreen.xib */,
@@ -371,6 +374,7 @@
371374
buildActionMask = 2147483647;
372375
files = (
373376
607FACD81AFB9204008FA782 /* VerificationCodeViewController.swift in Sources */,
377+
D1AA5A4D20D0FD7B007FE474 /* ProgramaticalVerificationCodeViewController.swift in Sources */,
374378
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
375379
);
376380
runOnlyForDeploymentPostprocessing = 0;

Example/KWVerificationCodeView/Base.lproj/Main.storyboard

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C68" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<scenes>
@@ -69,9 +69,17 @@
6969
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
7070
<nil key="highlightedColor"/>
7171
</label>
72+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="z9m-CU-XT6">
73+
<rect key="frame" x="88" y="447" width="200" height="30"/>
74+
<state key="normal" title="Add Programatically Example"/>
75+
<connections>
76+
<segue destination="ViW-Wf-OWW" kind="presentation" id="PCu-5s-Oao"/>
77+
</connections>
78+
</button>
7279
</subviews>
7380
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
7481
<constraints>
82+
<constraint firstItem="z9m-CU-XT6" firstAttribute="top" secondItem="Skh-28-8br" secondAttribute="bottom" constant="50" id="3ER-Pd-VZR"/>
7583
<constraint firstItem="ekS-Ew-GpT" firstAttribute="top" secondItem="P6k-pN-VEP" secondAttribute="bottom" constant="22" id="H7u-LC-n82"/>
7684
<constraint firstItem="ekS-Ew-GpT" firstAttribute="top" secondItem="6e0-Am-MUv" secondAttribute="bottom" constant="90" id="HQQ-Ne-ux5"/>
7785
<constraint firstItem="6e0-Am-MUv" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" constant="16" id="K9Y-GQ-xFr"/>
@@ -80,6 +88,7 @@
8088
<constraint firstItem="Skh-28-8br" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="bUo-66-X5C"/>
8189
<constraint firstItem="P6k-pN-VEP" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="nb6-py-4Yg"/>
8290
<constraint firstItem="ekS-Ew-GpT" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="rI6-Fp-Ztx"/>
91+
<constraint firstItem="z9m-CU-XT6" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="rwf-e1-tIX"/>
8392
<constraint firstItem="ekS-Ew-GpT" firstAttribute="centerY" secondItem="kh9-bI-dsS" secondAttribute="centerY" constant="-30" id="vWu-wt-SXh"/>
8493
</constraints>
8594
</view>
@@ -92,5 +101,65 @@
92101
</objects>
93102
<point key="canvasLocation" x="-372" y="100"/>
94103
</scene>
104+
<!--Programatical Verification Code View Controller-->
105+
<scene sceneID="PcA-p8-RcH">
106+
<objects>
107+
<viewController id="ViW-Wf-OWW" customClass="ProgramaticalVerificationCodeViewController" customModule="KWVerificationCodeView_Example" customModuleProvider="target" sceneMemberID="viewController">
108+
<layoutGuides>
109+
<viewControllerLayoutGuide type="top" id="mMV-mk-sPq"/>
110+
<viewControllerLayoutGuide type="bottom" id="wLY-h7-h8W"/>
111+
</layoutGuides>
112+
<view key="view" contentMode="scaleToFill" id="4Uy-b5-xy6">
113+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
114+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
115+
<subviews>
116+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Add KWVerificationCode Programatically" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f6U-8u-Nd6" userLabel="titleLabel">
117+
<rect key="frame" x="61.5" y="203.5" width="252" height="49"/>
118+
<constraints>
119+
<constraint firstAttribute="width" constant="252" id="IZ7-B5-xnh"/>
120+
</constraints>
121+
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle3"/>
122+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
123+
<nil key="highlightedColor"/>
124+
</label>
125+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EO4-xT-id3" userLabel="containerView">
126+
<rect key="frame" x="67" y="302.5" width="240" height="62"/>
127+
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
128+
<constraints>
129+
<constraint firstAttribute="width" constant="240" id="ZKT-ZX-ywp"/>
130+
<constraint firstAttribute="height" constant="62" id="nlq-5k-PEm"/>
131+
</constraints>
132+
<userDefinedRuntimeAttributes>
133+
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
134+
<integer key="value" value="5"/>
135+
</userDefinedRuntimeAttribute>
136+
</userDefinedRuntimeAttributes>
137+
</view>
138+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a7r-Cg-pzE" userLabel="dismiss">
139+
<rect key="frame" x="160.5" y="414.5" width="54" height="30"/>
140+
<state key="normal" title="Dismiss"/>
141+
<connections>
142+
<action selector="dismissButtonTapped:" destination="ViW-Wf-OWW" eventType="touchUpInside" id="XuZ-EC-sB8"/>
143+
</connections>
144+
</button>
145+
</subviews>
146+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
147+
<constraints>
148+
<constraint firstItem="EO4-xT-id3" firstAttribute="centerX" secondItem="4Uy-b5-xy6" secondAttribute="centerX" id="7ZN-6l-dPq"/>
149+
<constraint firstItem="a7r-Cg-pzE" firstAttribute="centerX" secondItem="4Uy-b5-xy6" secondAttribute="centerX" id="8CX-Km-yfc"/>
150+
<constraint firstItem="f6U-8u-Nd6" firstAttribute="centerX" secondItem="4Uy-b5-xy6" secondAttribute="centerX" id="AdM-x2-67B"/>
151+
<constraint firstItem="a7r-Cg-pzE" firstAttribute="top" secondItem="EO4-xT-id3" secondAttribute="bottom" constant="50" id="idc-nu-If0"/>
152+
<constraint firstItem="EO4-xT-id3" firstAttribute="centerY" secondItem="4Uy-b5-xy6" secondAttribute="centerY" id="m5d-Xg-QG5"/>
153+
<constraint firstItem="EO4-xT-id3" firstAttribute="top" secondItem="f6U-8u-Nd6" secondAttribute="bottom" constant="50" id="uVk-oY-Aj5"/>
154+
</constraints>
155+
</view>
156+
<connections>
157+
<outlet property="containerView" destination="EO4-xT-id3" id="fLF-6n-1kx"/>
158+
</connections>
159+
</viewController>
160+
<placeholder placeholderIdentifier="IBFirstResponder" id="Plo-FI-tAh" userLabel="First Responder" sceneMemberID="firstResponder"/>
161+
</objects>
162+
<point key="canvasLocation" x="496.80000000000001" y="98.50074962518741"/>
163+
</scene>
95164
</scenes>
96165
</document>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// VerificationCodeViewController.swift
3+
// KWVerificationCodeView
4+
//
5+
// Created by KeepWorks on 01/10/2017.
6+
// Copyright (c) 2017 KeepWorks Technologies Pvt Ltd. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import KWVerificationCodeView
11+
12+
class ProgramaticalVerificationCodeViewController: UIViewController {
13+
14+
// MARK: - IBOutlets
15+
@IBOutlet weak var containerView: UIView!
16+
17+
// MARK: - Lifecycle
18+
override func viewDidLoad() {
19+
super.viewDidLoad()
20+
21+
let verificationCodeView = KWVerificationCodeView(frame: CGRect(x: 0, y: 0, width: 240, height: 60))
22+
containerView.addSubview(verificationCodeView)
23+
}
24+
25+
@IBAction func dismissButtonTapped(_ sender: Any) {
26+
dismiss(animated: true, completion: nil)
27+
}
28+
}
29+

0 commit comments

Comments
 (0)