├── Images ├── 1.png └── 2.png ├── CVPasscodeControllerExample ├── Assets.xcassets │ ├── Contents.json │ ├── Sample.imageset │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── AppDelegate.swift └── ViewController.swift ├── CVPasscodeController.xcodeproj ├── xcuserdata │ └── unixzii.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── CVPasscodeControllerExample.xcscheme ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── unixzii.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── xcshareddata │ └── xcschemes │ │ └── CVPasscodeController.xcscheme └── project.pbxproj ├── CVPasscodeController ├── CVPasscodeController.h ├── Info.plist └── Classes │ ├── CVKeypad.swift │ ├── CVPasscodeIndicator.swift │ ├── CVKeypadCell.swift │ └── CVPasscodeController.swift ├── LICENSE └── README.md /Images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unixzii/CVPasscodeController/HEAD/Images/1.png -------------------------------------------------------------------------------- /Images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unixzii/CVPasscodeController/HEAD/Images/2.png -------------------------------------------------------------------------------- /CVPasscodeControllerExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CVPasscodeController.xcodeproj/xcuserdata/unixzii.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CVPasscodeController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CVPasscodeController.xcodeproj/project.xcworkspace/xcuserdata/unixzii.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unixzii/CVPasscodeController/HEAD/CVPasscodeController.xcodeproj/project.xcworkspace/xcuserdata/unixzii.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CVPasscodeControllerExample/Assets.xcassets/Sample.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "IMG_0224.PNG", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CVPasscodeController/CVPasscodeController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CVPasscodeController.h 3 | // CVPasscodeController 4 | // 5 | // Created by 杨弘宇 on 16/7/6. 6 | // Copyright © 2016年 Cyandev. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for CVPasscodeController. 12 | FOUNDATION_EXPORT double CVPasscodeControllerVersionNumber; 13 | 14 | //! Project version string for CVPasscodeController. 15 | FOUNDATION_EXPORT const unsigned char CVPasscodeControllerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /CVPasscodeControllerExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /CVPasscodeController.xcodeproj/xcuserdata/unixzii.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CVPasscodeController.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | CVPasscodeControllerExample.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 9DB997F11D2CD29D0092AE25 21 | 22 | primary 23 | 24 | 25 | 9DB998001D2CD2BA0092AE25 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /CVPasscodeController/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Cyandev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /CVPasscodeControllerExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /CVPasscodeController/Classes/CVKeypad.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CVKeypad.swift 3 | // CVPasscodeController 4 | // 5 | // Created by 杨弘宇 on 16/7/6. 6 | // Copyright © 2016年 Cyandev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CVKeypad: UIView { 12 | 13 | private(set) var keypadCells = [CVKeypadCell]() 14 | 15 | init() { 16 | super.init(frame: CGRect.zero) 17 | commonInit() 18 | } 19 | 20 | override init(frame: CGRect) { 21 | super.init(frame: frame) 22 | commonInit() 23 | } 24 | 25 | required init?(coder aDecoder: NSCoder) { 26 | fatalError("init(coder:) has not been implemented") 27 | } 28 | 29 | func commonInit() { 30 | for i in 1...10 { 31 | let cell = CVKeypadCell(frame: CGRect(x: 0, y: 0, width: 75, height: 75)) 32 | cell.text = "\(i == 10 ? 0 : i)" 33 | 34 | addSubview(cell) 35 | keypadCells.append(cell) 36 | } 37 | } 38 | 39 | override func layoutSubviews() { 40 | super.layoutSubviews() 41 | 42 | var col = 0 43 | var row = 0 44 | 45 | for cell in keypadCells { 46 | cell.frame.origin = CGPoint(x: col * 100, y: row * 100) 47 | 48 | col += 1 49 | if col > 2 { 50 | row += 1 51 | col = row == 3 ? 1 : 0 52 | } 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /CVPasscodeControllerExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CVPasscodeController 2 | 3 | A native looks passcode input interface. 4 | 5 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 6 | 7 | ## Introduction 8 | 9 | `CVPasscodeController` provide you with a easy way to achieve local authentication, which only requires you make little change in your project. 10 | 11 | ## Screenshot 12 | ![](https://raw.githubusercontent.com/unixzii/CVPasscodeController/master/Images/1.png) 13 | ![](https://raw.githubusercontent.com/unixzii/CVPasscodeController/master/Images/2.png) 14 | 15 | ## Features 16 | * Two interface style (dark / light). 17 | * Supports arbitrary digits. 18 | * Customizable interface strings. 19 | 20 | ## Example 21 | To run the example project, clone the repo, and build the example scheme. 22 | 23 | ## Installation 24 | CVPasscodeController is available through Carthage. To install it, simply add the following line to your Cartfile: 25 | 26 | ```bash 27 | github "unixzii/CVPasscodeController" 28 | ``` 29 | 30 | ## Usage Guide 31 | `CVPasscodeController` is the main class you will work on. 32 | Instantiate a `CVPasscodeController` object, pass a preferred style to its initializer. 33 | 34 | `CVPasscodeEvaluating` is another important protocol you need to implement, it allow the controller evaluate the passcode. 35 | One thing need to be concerned is your evaluating process should not block the main thread, it should return quickly. Before returning the result, you can schedule something that will happen after user input a correct passcode. For more, see the example project. 36 | 37 | Any strings appear on the interface can be customized, only thing you need to do is implement `CVPasscodeInterfaceStringProviding` protocol. 38 | 39 | After all thing is done, just present it as a view controller. 40 | 41 | ## License 42 | The project is available under the MIT license. See the LICENSE file for more info. 43 | -------------------------------------------------------------------------------- /CVPasscodeControllerExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CVPasscodeControllerExample 4 | // 5 | // Created by 杨弘宇 on 16/7/6. 6 | // Copyright © 2016年 Cyandev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /CVPasscodeController/Classes/CVPasscodeIndicator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CVPasscodeIndicator.swift 3 | // CVPasscodeController 4 | // 5 | // Created by 杨弘宇 on 16/7/6. 6 | // Copyright © 2016年 Cyandev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CVPasscodeIndicator: UIView { 12 | 13 | var interfaceVisualEffect: UIVisualEffect! 14 | 15 | private var vibrancyView: UIVisualEffectView! 16 | private var dotLayers = [CAShapeLayer]() 17 | 18 | init(countOfDigits: Int) { 19 | super.init(frame: CGRect.zero) 20 | 21 | vibrancyView = UIVisualEffectView(effect: nil) 22 | 23 | for _ in 0.. CGSize { 53 | return CGSize(width: 40 * dotLayers.count - 14, height: 16) 54 | } 55 | 56 | override func didMoveToWindow() { 57 | super.didMoveToWindow() 58 | 59 | vibrancyView.effect = UIVibrancyEffect(forBlurEffect: interfaceVisualEffect as! UIBlurEffect) 60 | } 61 | 62 | func setNumberOfFilledDot(number: Int) { 63 | for (i, dotLayer) in dotLayers.enumerate() { 64 | if i < number { 65 | dotLayer.fillColor = UIColor.whiteColor().CGColor 66 | } else { 67 | dotLayer.fillColor = nil 68 | } 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /CVPasscodeControllerExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CVPasscodeControllerExample 4 | // 5 | // Created by 杨弘宇 on 16/7/6. 6 | // Copyright © 2016年 Cyandev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CVPasscodeController 11 | 12 | class ViewController: UIViewController { 13 | 14 | override func prefersStatusBarHidden() -> Bool { 15 | return true 16 | } 17 | 18 | @IBAction func viewDidSwipe(sender: AnyObject) { 19 | let passcodeController = CVPasscodeController(interfaceStyle: .Dark) 20 | passcodeController.passcodeEvaluator = self 21 | 22 | presentViewController(passcodeController, animated: true, completion: nil) 23 | } 24 | 25 | @IBAction func viewDidTap(sender: AnyObject) { 26 | let passcodeController = CVPasscodeController(interfaceStyle: .Light) 27 | passcodeController.interfaceStringProvider = self 28 | passcodeController.passcodeEvaluator = self 29 | 30 | presentViewController(passcodeController, animated: true, completion: nil) 31 | } 32 | 33 | } 34 | 35 | 36 | extension ViewController: CVPasscodeEvaluating { 37 | 38 | func numberOfDigitsInPasscodeForPasscodeController(controller: CVPasscodeController) -> Int { 39 | return 6 40 | } 41 | 42 | func evaluatePasscode(passcode: String, forPasscodeController controller: CVPasscodeController) -> Bool { 43 | if passcode == "123456" { 44 | let alert = UIAlertController(title: "Content Unlocked", message: "This is some secret.", preferredStyle: .Alert) 45 | alert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: nil)) 46 | 47 | // Delay 300ms to prevent presenting another VC while passcode controller is still on presentation. You may replace this with your own solution. 48 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(NSEC_PER_MSEC * 300)), dispatch_get_main_queue()) { 49 | self.presentViewController(alert, animated: true, completion: nil) 50 | } 51 | 52 | return true 53 | } 54 | return false 55 | } 56 | 57 | func passcodeControllerDidCancel(controller: CVPasscodeController) { 58 | print("user cancelled") 59 | } 60 | 61 | } 62 | 63 | 64 | extension ViewController: CVPasscodeInterfaceStringProviding { 65 | 66 | func interfaceStringOfType(type: CVPasscodeInterfaceStringType, forPasscodeController controller: CVPasscodeController) -> String { 67 | switch type { 68 | case .Backspace: 69 | return "删除" 70 | case .Cancel: 71 | return "取消" 72 | case .InitialHint: 73 | return "输入密码以查看加密内容" 74 | case .WrongHint: 75 | return "密码错误,请重试" 76 | } 77 | } 78 | 79 | } 80 | 81 | -------------------------------------------------------------------------------- /CVPasscodeController.xcodeproj/xcshareddata/xcschemes/CVPasscodeController.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /CVPasscodeController.xcodeproj/xcuserdata/unixzii.xcuserdatad/xcschemes/CVPasscodeControllerExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /CVPasscodeControllerExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /CVPasscodeController/Classes/CVKeypadCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CVKeypadCell.swift 3 | // CVPasscodeController 4 | // 5 | // Created by 杨弘宇 on 16/7/6. 6 | // Copyright © 2016年 Cyandev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AudioToolbox 11 | 12 | class CVKeypadCell: UIControl { 13 | 14 | var text: String? 15 | var color: UIColor! 16 | var interfaceVisualEffect: UIVisualEffect! 17 | 18 | private var vibrancyView: UIVisualEffectView! 19 | private var outlineView: UIView! 20 | private var label: UILabel! 21 | 22 | private var outlineLayer: CAShapeLayer! 23 | 24 | override init(frame: CGRect) { 25 | super.init(frame: frame) 26 | commonInit() 27 | } 28 | 29 | required init?(coder aDecoder: NSCoder) { 30 | fatalError("init(coder:) has not been implemented") 31 | } 32 | 33 | func commonInit() { 34 | vibrancyView = UIVisualEffectView(effect: nil) 35 | outlineView = UIView() 36 | label = UILabel() 37 | 38 | outlineLayer = CAShapeLayer() 39 | outlineLayer.lineWidth = 2 40 | outlineLayer.strokeColor = UIColor.whiteColor().CGColor 41 | outlineLayer.fillColor = nil 42 | 43 | outlineView.layer.addSublayer(outlineLayer) 44 | 45 | vibrancyView.contentView.addSubview(outlineView) 46 | 47 | label.font = UIFont.systemFontOfSize(32, weight: UIFontWeightThin) 48 | label.textAlignment = .Center 49 | 50 | addSubview(vibrancyView) 51 | addSubview(label) 52 | } 53 | 54 | override func layoutSubviews() { 55 | super.layoutSubviews() 56 | 57 | vibrancyView.frame = bounds 58 | outlineView.frame = vibrancyView.bounds 59 | outlineLayer.frame = outlineView.bounds.insetBy(dx: 5, dy: 5).offsetBy(dx: -2.5, dy: -2.5) 60 | outlineLayer.path = CGPathCreateWithEllipseInRect(outlineLayer.frame, nil) 61 | 62 | label.frame = bounds 63 | } 64 | 65 | override func didMoveToWindow() { 66 | super.didMoveToWindow() 67 | 68 | vibrancyView.effect = UIVibrancyEffect(forBlurEffect: interfaceVisualEffect as! UIBlurEffect) 69 | label.textColor = color 70 | label.text = text 71 | } 72 | 73 | // MARK: - Touch event handlers 74 | 75 | override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? { 76 | let distance = sqrt(pow(point.x - CGRectGetMidX(bounds), 2) + pow(point.y - CGRectGetMidY(bounds), 2)) 77 | 78 | return distance <= bounds.width / 2.0 ? self : nil 79 | } 80 | 81 | override func touchesBegan(touches: Set, withEvent event: UIEvent?) { 82 | super.touchesBegan(touches, withEvent: event) 83 | 84 | AudioServicesPlaySystemSound(1104) 85 | 86 | setFillColor(UIColor.whiteColor(), labelColor: UIColor.whiteColor(), animated: false) 87 | } 88 | 89 | override func touchesEnded(touches: Set, withEvent event: UIEvent?) { 90 | super.touchesEnded(touches, withEvent: event) 91 | 92 | setFillColor(UIColor.clearColor(), labelColor: color, animated: true) 93 | } 94 | 95 | override func touchesCancelled(touches: Set?, withEvent event: UIEvent?) { 96 | super.touchesCancelled(touches, withEvent: event) 97 | 98 | setFillColor(UIColor.clearColor(), labelColor: color, animated: true) 99 | } 100 | 101 | // MARK: - Private methods 102 | 103 | func setFillColor(color: UIColor, labelColor: UIColor, animated: Bool) { 104 | CATransaction.begin() 105 | if animated { 106 | UIView.beginAnimations(nil, context: nil) 107 | UIView.setAnimationDuration(0.6) 108 | CATransaction.setAnimationDuration(0.6) 109 | 110 | defer { 111 | UIView.commitAnimations() 112 | } 113 | } else { 114 | CATransaction.setDisableActions(true) 115 | } 116 | outlineLayer.fillColor = color.CGColor 117 | label.textColor = labelColor 118 | CATransaction.commit() 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /CVPasscodeController/Classes/CVPasscodeController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CVPasscodeController.swift 3 | // CVPasscodeController 4 | // 5 | // Created by 杨弘宇 on 16/7/6. 6 | // Copyright © 2016年 Cyandev. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AudioToolbox 11 | 12 | public enum CVPasscodeInterfaceStyle { 13 | case Dark 14 | case Light 15 | } 16 | 17 | 18 | public enum CVPasscodeInterfaceStringType { 19 | case InitialHint 20 | case WrongHint 21 | case Cancel 22 | case Backspace 23 | } 24 | 25 | 26 | public protocol CVPasscodeInterfaceStringProviding { 27 | func interfaceStringOfType(type: CVPasscodeInterfaceStringType, forPasscodeController controller: CVPasscodeController) -> String 28 | } 29 | 30 | 31 | public protocol CVPasscodeEvaluating { 32 | // Return the number of digits in this method to initialize the digit indicator and help the controller judge the end of user inputting. 33 | func numberOfDigitsInPasscodeForPasscodeController(controller: CVPasscodeController) -> Int 34 | 35 | // This will be called after the designated digits finished being inputted, if true was returned then the controller will dismiss, otherwise, the device will vibrate and there will be some visual feedback to tell user the passcode was wrong. 36 | func evaluatePasscode(passcode: String, forPasscodeController controller: CVPasscodeController) -> Bool 37 | 38 | // This will be called after user tapped the cancel button and controller has dismissed. 39 | func passcodeControllerDidCancel(controller: CVPasscodeController) 40 | } 41 | 42 | 43 | public class CVPasscodeController: UIViewController { 44 | 45 | private var hintLabel: UILabel! 46 | private var backspaceButton: UIButton! 47 | private var keypad: CVKeypad! 48 | private var indicator: CVPasscodeIndicator! 49 | 50 | private var currentInput = "" 51 | private var numberOfDigits: Int! 52 | private var evaluating = false 53 | 54 | public var interfaceStringProvider: CVPasscodeInterfaceStringProviding? // Set this to provide custom localized interface strings. 55 | public var passcodeEvaluator: CVPasscodeEvaluating! // This property must be set to tell the controller whether the passcode user input is valid. 56 | 57 | public let interfaceStyle: CVPasscodeInterfaceStyle // The getter of current interface style. 58 | 59 | public init(interfaceStyle: CVPasscodeInterfaceStyle) { 60 | self.interfaceStyle = interfaceStyle 61 | super.init(nibName: nil, bundle: nil) 62 | 63 | modalPresentationStyle = .Custom 64 | transitioningDelegate = self 65 | } 66 | 67 | public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { 68 | self.interfaceStyle = .Dark 69 | super.init(nibName: nil, bundle: nil) 70 | } 71 | 72 | public required init?(coder aDecoder: NSCoder) { 73 | self.interfaceStyle = .Dark 74 | super.init(coder: aDecoder) 75 | } 76 | 77 | convenience init() { 78 | self.init(interfaceStyle: .Dark) 79 | } 80 | 81 | public override func loadView() { 82 | super.loadView() 83 | 84 | assert(passcodeEvaluator != nil, "Evaluator must be set before controller presented.") 85 | numberOfDigits = passcodeEvaluator.numberOfDigitsInPasscodeForPasscodeController(self) 86 | 87 | let blackColor = UIColor.blackColor() 88 | let whiteColor = UIColor.whiteColor() 89 | 90 | hintLabel = UILabel() 91 | backspaceButton = UIButton(type: .System) 92 | keypad = CVKeypad() 93 | indicator = CVPasscodeIndicator(countOfDigits: numberOfDigits) 94 | 95 | hintLabel.translatesAutoresizingMaskIntoConstraints = false 96 | hintLabel.font = UIFont.systemFontOfSize(19) 97 | hintLabel.textColor = interfaceStyle == .Dark ? whiteColor : blackColor 98 | hintLabel.text = interfaceStringProvider?.interfaceStringOfType(.InitialHint, forPasscodeController: self) ?? "Enter Passcode" 99 | 100 | backspaceButton.tintColor = interfaceStyle == .Dark ? whiteColor : blackColor 101 | backspaceButton.translatesAutoresizingMaskIntoConstraints = false 102 | backspaceButton.addTarget(self, action: #selector(cancel), forControlEvents: .TouchUpInside) 103 | updateBackspaceButtonTitle() 104 | 105 | let interfaceVisualEffect = UIBlurEffect(style: self.interfaceStyle == .Dark ? .Dark : .ExtraLight) 106 | 107 | keypad.translatesAutoresizingMaskIntoConstraints = false 108 | keypad.keypadCells.forEach { cell in 109 | cell.color = self.interfaceStyle == .Dark ? whiteColor : blackColor 110 | cell.interfaceVisualEffect = interfaceVisualEffect 111 | cell.addTarget(self, action: #selector(cellDidTap(_:)), forControlEvents: .TouchDown) 112 | } 113 | 114 | indicator.translatesAutoresizingMaskIntoConstraints = false 115 | indicator.interfaceVisualEffect = interfaceVisualEffect 116 | 117 | view.addSubview(hintLabel) 118 | view.addSubview(backspaceButton) 119 | view.addSubview(keypad) 120 | view.addSubview(indicator) 121 | 122 | view.addConstraint(NSLayoutConstraint( 123 | item: hintLabel, 124 | attribute: .CenterY, 125 | relatedBy: .Equal, 126 | toItem: view, 127 | attribute: .CenterY, 128 | multiplier: 1.0, 129 | constant: -230) 130 | ) 131 | 132 | view.addConstraint(NSLayoutConstraint( 133 | item: hintLabel, 134 | attribute: .CenterX, 135 | relatedBy: .Equal, 136 | toItem: view, 137 | attribute: .CenterX, 138 | multiplier: 1.0, 139 | constant: 0) 140 | ) 141 | 142 | view.addConstraint(NSLayoutConstraint( 143 | item: backspaceButton, 144 | attribute: .Bottom, 145 | relatedBy: .Equal, 146 | toItem: view, 147 | attribute: .Bottom, 148 | multiplier: 1.0, 149 | constant: -35) 150 | ) 151 | 152 | view.addConstraint(NSLayoutConstraint( 153 | item: backspaceButton, 154 | attribute: .CenterX, 155 | relatedBy: .Equal, 156 | toItem: view, 157 | attribute: .CenterX, 158 | multiplier: 1.0, 159 | constant: 0) 160 | ) 161 | 162 | view.addConstraint(NSLayoutConstraint( 163 | item: keypad, 164 | attribute: .CenterY, 165 | relatedBy: .Equal, 166 | toItem: view, 167 | attribute: .CenterY, 168 | multiplier: 1.0, 169 | constant: 50) 170 | ) 171 | 172 | view.addConstraint(NSLayoutConstraint( 173 | item: keypad, 174 | attribute: .CenterX, 175 | relatedBy: .Equal, 176 | toItem: view, 177 | attribute: .CenterX, 178 | multiplier: 1.0, 179 | constant: 0) 180 | ) 181 | 182 | view.addConstraint(NSLayoutConstraint( 183 | item: keypad, 184 | attribute: .Width, 185 | relatedBy: .Equal, 186 | toItem: nil, 187 | attribute: .NotAnAttribute, 188 | multiplier: 1.0, 189 | constant: 275) 190 | ) 191 | 192 | view.addConstraint(NSLayoutConstraint( 193 | item: keypad, 194 | attribute: .Height, 195 | relatedBy: .Equal, 196 | toItem: nil, 197 | attribute: .NotAnAttribute, 198 | multiplier: 1.0, 199 | constant: 375) 200 | ) 201 | 202 | view.addConstraint(NSLayoutConstraint( 203 | item: indicator, 204 | attribute: .Top, 205 | relatedBy: .Equal, 206 | toItem: hintLabel, 207 | attribute: .Bottom, 208 | multiplier: 1.0, 209 | constant: 15) 210 | ) 211 | 212 | view.addConstraint(NSLayoutConstraint( 213 | item: indicator, 214 | attribute: .CenterX, 215 | relatedBy: .Equal, 216 | toItem: view, 217 | attribute: .CenterX, 218 | multiplier: 1.0, 219 | constant: 0) 220 | ) 221 | } 222 | 223 | public override func preferredStatusBarStyle() -> UIStatusBarStyle { 224 | return interfaceStyle == .Dark ? .LightContent : .Default 225 | } 226 | 227 | public override func shouldAutorotate() -> Bool { 228 | return false 229 | } 230 | 231 | public override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation { 232 | return .Portrait 233 | } 234 | 235 | public override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { 236 | return .Portrait 237 | } 238 | 239 | // MARK: - Private methods 240 | 241 | private func updateBackspaceButtonTitle() { 242 | let title: String 243 | if currentInput.characters.count == 0 { 244 | title = interfaceStringProvider?.interfaceStringOfType(.Cancel, forPasscodeController: self) ?? "Cancel" 245 | } else { 246 | title = interfaceStringProvider?.interfaceStringOfType(.Backspace, forPasscodeController: self) ?? "Delete" 247 | } 248 | 249 | backspaceButton.setTitle(title, forState: .Normal) 250 | } 251 | 252 | @objc private func cellDidTap(sender: AnyObject?) { 253 | if evaluating { 254 | return 255 | } 256 | 257 | if let cell = sender as? CVKeypadCell { 258 | let digitString = cell.text! 259 | currentInput += digitString 260 | indicator.setNumberOfFilledDot(currentInput.characters.count) 261 | updateBackspaceButtonTitle() 262 | if currentInput.characters.count == numberOfDigits { 263 | evaluating = true 264 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(NSEC_PER_MSEC * 200)), dispatch_get_main_queue()) { 265 | self.evaluatePasscode() 266 | self.evaluating = false 267 | } 268 | } 269 | } 270 | } 271 | 272 | @objc private func cancel() { 273 | if currentInput.characters.count == 0 { 274 | dismissViewControllerAnimated(true, completion: nil) 275 | } else { 276 | currentInput = currentInput.substringToIndex(currentInput.endIndex.predecessor()) 277 | indicator.setNumberOfFilledDot(currentInput.characters.count) 278 | updateBackspaceButtonTitle() 279 | } 280 | } 281 | 282 | private func evaluatePasscode() { 283 | if passcodeEvaluator.evaluatePasscode(currentInput, forPasscodeController: self) { 284 | dismissViewControllerAnimated(true, completion: nil) 285 | } else { 286 | currentInput = "" 287 | indicator.setNumberOfFilledDot(0) 288 | updateBackspaceButtonTitle() 289 | performRetryFeedback() 290 | } 291 | } 292 | 293 | private func performRetryFeedback() { 294 | // First, shake the indicator view. 295 | let shakeAnimation = CAKeyframeAnimation(keyPath: "transform.translation.x") 296 | shakeAnimation.values = [-20, 19, -18, 17, -15, 12, -6, 2, 0].map({ return NSNumber(int: $0) }) 297 | shakeAnimation.duration = 0.6 298 | indicator.layer.addAnimation(shakeAnimation, forKey: "shake") 299 | 300 | // Second, set the hint label. 301 | UIView.transitionWithView(hintLabel, duration: 0.3, options: .TransitionCrossDissolve, animations: { 302 | self.hintLabel.text = self.interfaceStringProvider?.interfaceStringOfType(.WrongHint, forPasscodeController: self) ?? "Wrong passcode, try again" 303 | }, completion: nil) 304 | 305 | // Third, vibrate the device. 306 | AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) 307 | } 308 | 309 | } 310 | 311 | 312 | extension CVPasscodeController: UIViewControllerTransitioningDelegate { 313 | 314 | class CVPasscodePresentationController: UIPresentationController { 315 | 316 | private var blurBackgroundView: UIVisualEffectView! 317 | 318 | override func presentationTransitionWillBegin() { 319 | super.presentationTransitionWillBegin() 320 | 321 | guard containerView != nil else { 322 | return 323 | } 324 | 325 | blurBackgroundView = UIVisualEffectView(effect: nil) 326 | blurBackgroundView.frame = containerView!.bounds 327 | 328 | containerView!.addSubview(blurBackgroundView) 329 | 330 | presentedViewController.transitionCoordinator()?.animateAlongsideTransition({ _ in 331 | let interfaceStyle = (self.presentedViewController as! CVPasscodeController).interfaceStyle 332 | self.blurBackgroundView.effect = UIBlurEffect(style: interfaceStyle == .Dark ? .Dark : .ExtraLight) 333 | }, completion: nil) 334 | } 335 | 336 | override func presentationTransitionDidEnd(completed: Bool) { 337 | super.presentationTransitionDidEnd(completed) 338 | 339 | if !completed && blurBackgroundView != nil { 340 | blurBackgroundView.removeFromSuperview() 341 | } 342 | } 343 | 344 | override func dismissalTransitionWillBegin() { 345 | super.dismissalTransitionWillBegin() 346 | 347 | guard blurBackgroundView != nil else { 348 | return 349 | } 350 | 351 | presentedViewController.transitionCoordinator()?.animateAlongsideTransition({ _ in 352 | self.blurBackgroundView.effect = nil 353 | }, completion: nil) 354 | } 355 | 356 | override func dismissalTransitionDidEnd(completed: Bool) { 357 | super.dismissalTransitionDidEnd(completed) 358 | 359 | if completed && blurBackgroundView != nil { 360 | blurBackgroundView.removeFromSuperview() 361 | } 362 | } 363 | 364 | } 365 | 366 | public func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? { 367 | return CVPasscodePresentationController(presentedViewController: presented, presentingViewController: presenting) 368 | } 369 | 370 | } 371 | -------------------------------------------------------------------------------- /CVPasscodeController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9D32D14F1D2E28CD00D44F32 /* CVPasscodeController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DB997F21D2CD29D0092AE25 /* CVPasscodeController.framework */; }; 11 | 9D32D1501D2E28CD00D44F32 /* CVPasscodeController.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9DB997F21D2CD29D0092AE25 /* CVPasscodeController.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | 9D8AB9331D2D09DD00F6D58F /* CVPasscodeIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D8AB9321D2D09DD00F6D58F /* CVPasscodeIndicator.swift */; }; 13 | 9DB997F61D2CD29D0092AE25 /* CVPasscodeController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DB997F51D2CD29D0092AE25 /* CVPasscodeController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 14 | 9DB998041D2CD2BA0092AE25 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DB998031D2CD2BA0092AE25 /* AppDelegate.swift */; }; 15 | 9DB998061D2CD2BA0092AE25 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DB998051D2CD2BA0092AE25 /* ViewController.swift */; }; 16 | 9DB998091D2CD2BA0092AE25 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DB998071D2CD2BA0092AE25 /* Main.storyboard */; }; 17 | 9DB9980B1D2CD2BA0092AE25 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9DB9980A1D2CD2BA0092AE25 /* Assets.xcassets */; }; 18 | 9DB9980E1D2CD2BA0092AE25 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DB9980C1D2CD2BA0092AE25 /* LaunchScreen.storyboard */; }; 19 | 9DB998151D2CD3210092AE25 /* CVPasscodeController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DB998141D2CD3210092AE25 /* CVPasscodeController.swift */; }; 20 | 9DE38CED1D2CDED600B8EC79 /* CVKeypadCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE38CEC1D2CDED600B8EC79 /* CVKeypadCell.swift */; }; 21 | 9DE38CEF1D2CE0C700B8EC79 /* CVKeypad.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DE38CEE1D2CE0C700B8EC79 /* CVKeypad.swift */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 9D32D1511D2E28CD00D44F32 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 9DB997E91D2CD29D0092AE25 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 9DB997F11D2CD29D0092AE25; 30 | remoteInfo = CVPasscodeController; 31 | }; 32 | /* End PBXContainerItemProxy section */ 33 | 34 | /* Begin PBXCopyFilesBuildPhase section */ 35 | 9D32D1531D2E28CD00D44F32 /* Embed Frameworks */ = { 36 | isa = PBXCopyFilesBuildPhase; 37 | buildActionMask = 2147483647; 38 | dstPath = ""; 39 | dstSubfolderSpec = 10; 40 | files = ( 41 | 9D32D1501D2E28CD00D44F32 /* CVPasscodeController.framework in Embed Frameworks */, 42 | ); 43 | name = "Embed Frameworks"; 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | /* End PBXCopyFilesBuildPhase section */ 47 | 48 | /* Begin PBXFileReference section */ 49 | 9D8AB9321D2D09DD00F6D58F /* CVPasscodeIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CVPasscodeIndicator.swift; sourceTree = ""; }; 50 | 9DB997F21D2CD29D0092AE25 /* CVPasscodeController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CVPasscodeController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 9DB997F51D2CD29D0092AE25 /* CVPasscodeController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CVPasscodeController.h; sourceTree = ""; }; 52 | 9DB997F71D2CD29D0092AE25 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 9DB998011D2CD2BA0092AE25 /* CVPasscodeControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CVPasscodeControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 9DB998031D2CD2BA0092AE25 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 55 | 9DB998051D2CD2BA0092AE25 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 56 | 9DB998081D2CD2BA0092AE25 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 57 | 9DB9980A1D2CD2BA0092AE25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 58 | 9DB9980D1D2CD2BA0092AE25 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 59 | 9DB9980F1D2CD2BA0092AE25 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | 9DB998141D2CD3210092AE25 /* CVPasscodeController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CVPasscodeController.swift; sourceTree = ""; }; 61 | 9DE38CEC1D2CDED600B8EC79 /* CVKeypadCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CVKeypadCell.swift; sourceTree = ""; }; 62 | 9DE38CEE1D2CE0C700B8EC79 /* CVKeypad.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CVKeypad.swift; sourceTree = ""; }; 63 | /* End PBXFileReference section */ 64 | 65 | /* Begin PBXFrameworksBuildPhase section */ 66 | 9DB997EE1D2CD29D0092AE25 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | 9DB997FE1D2CD2BA0092AE25 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | 9D32D14F1D2E28CD00D44F32 /* CVPasscodeController.framework in Frameworks */, 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 9DB997E81D2CD29D0092AE25 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 9DB997F41D2CD29D0092AE25 /* CVPasscodeController */, 88 | 9DB998021D2CD2BA0092AE25 /* CVPasscodeControllerExample */, 89 | 9DB997F31D2CD29D0092AE25 /* Products */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | 9DB997F31D2CD29D0092AE25 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 9DB997F21D2CD29D0092AE25 /* CVPasscodeController.framework */, 97 | 9DB998011D2CD2BA0092AE25 /* CVPasscodeControllerExample.app */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 9DB997F41D2CD29D0092AE25 /* CVPasscodeController */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 9DB998131D2CD2DF0092AE25 /* Classes */, 106 | 9DB997F51D2CD29D0092AE25 /* CVPasscodeController.h */, 107 | 9DB997F71D2CD29D0092AE25 /* Info.plist */, 108 | ); 109 | path = CVPasscodeController; 110 | sourceTree = ""; 111 | }; 112 | 9DB998021D2CD2BA0092AE25 /* CVPasscodeControllerExample */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 9DB998031D2CD2BA0092AE25 /* AppDelegate.swift */, 116 | 9DB998051D2CD2BA0092AE25 /* ViewController.swift */, 117 | 9DB998071D2CD2BA0092AE25 /* Main.storyboard */, 118 | 9DB9980A1D2CD2BA0092AE25 /* Assets.xcassets */, 119 | 9DB9980C1D2CD2BA0092AE25 /* LaunchScreen.storyboard */, 120 | 9DB9980F1D2CD2BA0092AE25 /* Info.plist */, 121 | ); 122 | path = CVPasscodeControllerExample; 123 | sourceTree = ""; 124 | }; 125 | 9DB998131D2CD2DF0092AE25 /* Classes */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 9DB998141D2CD3210092AE25 /* CVPasscodeController.swift */, 129 | 9DE38CEC1D2CDED600B8EC79 /* CVKeypadCell.swift */, 130 | 9DE38CEE1D2CE0C700B8EC79 /* CVKeypad.swift */, 131 | 9D8AB9321D2D09DD00F6D58F /* CVPasscodeIndicator.swift */, 132 | ); 133 | path = Classes; 134 | sourceTree = ""; 135 | }; 136 | /* End PBXGroup section */ 137 | 138 | /* Begin PBXHeadersBuildPhase section */ 139 | 9DB997EF1D2CD29D0092AE25 /* Headers */ = { 140 | isa = PBXHeadersBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 9DB997F61D2CD29D0092AE25 /* CVPasscodeController.h in Headers */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXHeadersBuildPhase section */ 148 | 149 | /* Begin PBXNativeTarget section */ 150 | 9DB997F11D2CD29D0092AE25 /* CVPasscodeController */ = { 151 | isa = PBXNativeTarget; 152 | buildConfigurationList = 9DB997FA1D2CD29D0092AE25 /* Build configuration list for PBXNativeTarget "CVPasscodeController" */; 153 | buildPhases = ( 154 | 9DB997ED1D2CD29D0092AE25 /* Sources */, 155 | 9DB997EE1D2CD29D0092AE25 /* Frameworks */, 156 | 9DB997EF1D2CD29D0092AE25 /* Headers */, 157 | 9DB997F01D2CD29D0092AE25 /* Resources */, 158 | ); 159 | buildRules = ( 160 | ); 161 | dependencies = ( 162 | ); 163 | name = CVPasscodeController; 164 | productName = CVPasscodeController; 165 | productReference = 9DB997F21D2CD29D0092AE25 /* CVPasscodeController.framework */; 166 | productType = "com.apple.product-type.framework"; 167 | }; 168 | 9DB998001D2CD2BA0092AE25 /* CVPasscodeControllerExample */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = 9DB998101D2CD2BA0092AE25 /* Build configuration list for PBXNativeTarget "CVPasscodeControllerExample" */; 171 | buildPhases = ( 172 | 9DB997FD1D2CD2BA0092AE25 /* Sources */, 173 | 9DB997FE1D2CD2BA0092AE25 /* Frameworks */, 174 | 9DB997FF1D2CD2BA0092AE25 /* Resources */, 175 | 9D32D1531D2E28CD00D44F32 /* Embed Frameworks */, 176 | ); 177 | buildRules = ( 178 | ); 179 | dependencies = ( 180 | 9D32D1521D2E28CD00D44F32 /* PBXTargetDependency */, 181 | ); 182 | name = CVPasscodeControllerExample; 183 | productName = CVPasscodeControllerExample; 184 | productReference = 9DB998011D2CD2BA0092AE25 /* CVPasscodeControllerExample.app */; 185 | productType = "com.apple.product-type.application"; 186 | }; 187 | /* End PBXNativeTarget section */ 188 | 189 | /* Begin PBXProject section */ 190 | 9DB997E91D2CD29D0092AE25 /* Project object */ = { 191 | isa = PBXProject; 192 | attributes = { 193 | LastSwiftUpdateCheck = 0730; 194 | LastUpgradeCheck = 0730; 195 | ORGANIZATIONNAME = Cyandev; 196 | TargetAttributes = { 197 | 9DB997F11D2CD29D0092AE25 = { 198 | CreatedOnToolsVersion = 7.3; 199 | DevelopmentTeam = S8ZP685HLU; 200 | }; 201 | 9DB998001D2CD2BA0092AE25 = { 202 | CreatedOnToolsVersion = 7.3; 203 | DevelopmentTeam = S8ZP685HLU; 204 | }; 205 | }; 206 | }; 207 | buildConfigurationList = 9DB997EC1D2CD29D0092AE25 /* Build configuration list for PBXProject "CVPasscodeController" */; 208 | compatibilityVersion = "Xcode 3.2"; 209 | developmentRegion = English; 210 | hasScannedForEncodings = 0; 211 | knownRegions = ( 212 | en, 213 | Base, 214 | ); 215 | mainGroup = 9DB997E81D2CD29D0092AE25; 216 | productRefGroup = 9DB997F31D2CD29D0092AE25 /* Products */; 217 | projectDirPath = ""; 218 | projectRoot = ""; 219 | targets = ( 220 | 9DB997F11D2CD29D0092AE25 /* CVPasscodeController */, 221 | 9DB998001D2CD2BA0092AE25 /* CVPasscodeControllerExample */, 222 | ); 223 | }; 224 | /* End PBXProject section */ 225 | 226 | /* Begin PBXResourcesBuildPhase section */ 227 | 9DB997F01D2CD29D0092AE25 /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | 9DB997FF1D2CD2BA0092AE25 /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 9DB9980E1D2CD2BA0092AE25 /* LaunchScreen.storyboard in Resources */, 239 | 9DB9980B1D2CD2BA0092AE25 /* Assets.xcassets in Resources */, 240 | 9DB998091D2CD2BA0092AE25 /* Main.storyboard in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | /* End PBXResourcesBuildPhase section */ 245 | 246 | /* Begin PBXSourcesBuildPhase section */ 247 | 9DB997ED1D2CD29D0092AE25 /* Sources */ = { 248 | isa = PBXSourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | 9D8AB9331D2D09DD00F6D58F /* CVPasscodeIndicator.swift in Sources */, 252 | 9DE38CED1D2CDED600B8EC79 /* CVKeypadCell.swift in Sources */, 253 | 9DB998151D2CD3210092AE25 /* CVPasscodeController.swift in Sources */, 254 | 9DE38CEF1D2CE0C700B8EC79 /* CVKeypad.swift in Sources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | 9DB997FD1D2CD2BA0092AE25 /* Sources */ = { 259 | isa = PBXSourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | 9DB998061D2CD2BA0092AE25 /* ViewController.swift in Sources */, 263 | 9DB998041D2CD2BA0092AE25 /* AppDelegate.swift in Sources */, 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | /* End PBXSourcesBuildPhase section */ 268 | 269 | /* Begin PBXTargetDependency section */ 270 | 9D32D1521D2E28CD00D44F32 /* PBXTargetDependency */ = { 271 | isa = PBXTargetDependency; 272 | target = 9DB997F11D2CD29D0092AE25 /* CVPasscodeController */; 273 | targetProxy = 9D32D1511D2E28CD00D44F32 /* PBXContainerItemProxy */; 274 | }; 275 | /* End PBXTargetDependency section */ 276 | 277 | /* Begin PBXVariantGroup section */ 278 | 9DB998071D2CD2BA0092AE25 /* Main.storyboard */ = { 279 | isa = PBXVariantGroup; 280 | children = ( 281 | 9DB998081D2CD2BA0092AE25 /* Base */, 282 | ); 283 | name = Main.storyboard; 284 | sourceTree = ""; 285 | }; 286 | 9DB9980C1D2CD2BA0092AE25 /* LaunchScreen.storyboard */ = { 287 | isa = PBXVariantGroup; 288 | children = ( 289 | 9DB9980D1D2CD2BA0092AE25 /* Base */, 290 | ); 291 | name = LaunchScreen.storyboard; 292 | sourceTree = ""; 293 | }; 294 | /* End PBXVariantGroup section */ 295 | 296 | /* Begin XCBuildConfiguration section */ 297 | 9DB997F81D2CD29D0092AE25 /* Debug */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_ANALYZER_NONNULL = YES; 302 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 303 | CLANG_CXX_LIBRARY = "libc++"; 304 | CLANG_ENABLE_MODULES = YES; 305 | CLANG_ENABLE_OBJC_ARC = YES; 306 | CLANG_WARN_BOOL_CONVERSION = YES; 307 | CLANG_WARN_CONSTANT_CONVERSION = YES; 308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 309 | CLANG_WARN_EMPTY_BODY = YES; 310 | CLANG_WARN_ENUM_CONVERSION = YES; 311 | CLANG_WARN_INT_CONVERSION = YES; 312 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 313 | CLANG_WARN_UNREACHABLE_CODE = YES; 314 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 315 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 316 | COPY_PHASE_STRIP = NO; 317 | CURRENT_PROJECT_VERSION = 1; 318 | DEBUG_INFORMATION_FORMAT = dwarf; 319 | ENABLE_STRICT_OBJC_MSGSEND = YES; 320 | ENABLE_TESTABILITY = YES; 321 | GCC_C_LANGUAGE_STANDARD = gnu99; 322 | GCC_DYNAMIC_NO_PIC = NO; 323 | GCC_NO_COMMON_BLOCKS = YES; 324 | GCC_OPTIMIZATION_LEVEL = 0; 325 | GCC_PREPROCESSOR_DEFINITIONS = ( 326 | "DEBUG=1", 327 | "$(inherited)", 328 | ); 329 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 330 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 331 | GCC_WARN_UNDECLARED_SELECTOR = YES; 332 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 333 | GCC_WARN_UNUSED_FUNCTION = YES; 334 | GCC_WARN_UNUSED_VARIABLE = YES; 335 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 336 | MTL_ENABLE_DEBUG_INFO = YES; 337 | ONLY_ACTIVE_ARCH = YES; 338 | SDKROOT = iphoneos; 339 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 340 | TARGETED_DEVICE_FAMILY = "1,2"; 341 | VERSIONING_SYSTEM = "apple-generic"; 342 | VERSION_INFO_PREFIX = ""; 343 | }; 344 | name = Debug; 345 | }; 346 | 9DB997F91D2CD29D0092AE25 /* Release */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ALWAYS_SEARCH_USER_PATHS = NO; 350 | CLANG_ANALYZER_NONNULL = YES; 351 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 352 | CLANG_CXX_LIBRARY = "libc++"; 353 | CLANG_ENABLE_MODULES = YES; 354 | CLANG_ENABLE_OBJC_ARC = YES; 355 | CLANG_WARN_BOOL_CONVERSION = YES; 356 | CLANG_WARN_CONSTANT_CONVERSION = YES; 357 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 358 | CLANG_WARN_EMPTY_BODY = YES; 359 | CLANG_WARN_ENUM_CONVERSION = YES; 360 | CLANG_WARN_INT_CONVERSION = YES; 361 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 362 | CLANG_WARN_UNREACHABLE_CODE = YES; 363 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 364 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 365 | COPY_PHASE_STRIP = NO; 366 | CURRENT_PROJECT_VERSION = 1; 367 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 368 | ENABLE_NS_ASSERTIONS = NO; 369 | ENABLE_STRICT_OBJC_MSGSEND = YES; 370 | GCC_C_LANGUAGE_STANDARD = gnu99; 371 | GCC_NO_COMMON_BLOCKS = YES; 372 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 373 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 374 | GCC_WARN_UNDECLARED_SELECTOR = YES; 375 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 376 | GCC_WARN_UNUSED_FUNCTION = YES; 377 | GCC_WARN_UNUSED_VARIABLE = YES; 378 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 379 | MTL_ENABLE_DEBUG_INFO = NO; 380 | SDKROOT = iphoneos; 381 | TARGETED_DEVICE_FAMILY = "1,2"; 382 | VALIDATE_PRODUCT = YES; 383 | VERSIONING_SYSTEM = "apple-generic"; 384 | VERSION_INFO_PREFIX = ""; 385 | }; 386 | name = Release; 387 | }; 388 | 9DB997FB1D2CD29D0092AE25 /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | CLANG_ENABLE_MODULES = YES; 392 | DEFINES_MODULE = YES; 393 | DYLIB_COMPATIBILITY_VERSION = 1; 394 | DYLIB_CURRENT_VERSION = 1; 395 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 396 | INFOPLIST_FILE = CVPasscodeController/Info.plist; 397 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 399 | PRODUCT_BUNDLE_IDENTIFIER = com.cyandev.CVPasscodeController; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | SKIP_INSTALL = YES; 402 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 403 | SWIFT_VERSION = 2.3; 404 | }; 405 | name = Debug; 406 | }; 407 | 9DB997FC1D2CD29D0092AE25 /* Release */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | CLANG_ENABLE_MODULES = YES; 411 | DEFINES_MODULE = YES; 412 | DYLIB_COMPATIBILITY_VERSION = 1; 413 | DYLIB_CURRENT_VERSION = 1; 414 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 415 | INFOPLIST_FILE = CVPasscodeController/Info.plist; 416 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 418 | PRODUCT_BUNDLE_IDENTIFIER = com.cyandev.CVPasscodeController; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | SKIP_INSTALL = YES; 421 | SWIFT_VERSION = 2.3; 422 | }; 423 | name = Release; 424 | }; 425 | 9DB998111D2CD2BA0092AE25 /* Debug */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 429 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 430 | INFOPLIST_FILE = CVPasscodeControllerExample/Info.plist; 431 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 432 | PRODUCT_BUNDLE_IDENTIFIER = com.cyandev.CVPasscodeControllerExample; 433 | PRODUCT_NAME = "$(TARGET_NAME)"; 434 | SWIFT_VERSION = 2.3; 435 | }; 436 | name = Debug; 437 | }; 438 | 9DB998121D2CD2BA0092AE25 /* Release */ = { 439 | isa = XCBuildConfiguration; 440 | buildSettings = { 441 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 442 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 443 | INFOPLIST_FILE = CVPasscodeControllerExample/Info.plist; 444 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 445 | PRODUCT_BUNDLE_IDENTIFIER = com.cyandev.CVPasscodeControllerExample; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | SWIFT_VERSION = 2.3; 448 | }; 449 | name = Release; 450 | }; 451 | /* End XCBuildConfiguration section */ 452 | 453 | /* Begin XCConfigurationList section */ 454 | 9DB997EC1D2CD29D0092AE25 /* Build configuration list for PBXProject "CVPasscodeController" */ = { 455 | isa = XCConfigurationList; 456 | buildConfigurations = ( 457 | 9DB997F81D2CD29D0092AE25 /* Debug */, 458 | 9DB997F91D2CD29D0092AE25 /* Release */, 459 | ); 460 | defaultConfigurationIsVisible = 0; 461 | defaultConfigurationName = Release; 462 | }; 463 | 9DB997FA1D2CD29D0092AE25 /* Build configuration list for PBXNativeTarget "CVPasscodeController" */ = { 464 | isa = XCConfigurationList; 465 | buildConfigurations = ( 466 | 9DB997FB1D2CD29D0092AE25 /* Debug */, 467 | 9DB997FC1D2CD29D0092AE25 /* Release */, 468 | ); 469 | defaultConfigurationIsVisible = 0; 470 | defaultConfigurationName = Release; 471 | }; 472 | 9DB998101D2CD2BA0092AE25 /* Build configuration list for PBXNativeTarget "CVPasscodeControllerExample" */ = { 473 | isa = XCConfigurationList; 474 | buildConfigurations = ( 475 | 9DB998111D2CD2BA0092AE25 /* Debug */, 476 | 9DB998121D2CD2BA0092AE25 /* Release */, 477 | ); 478 | defaultConfigurationIsVisible = 0; 479 | defaultConfigurationName = Release; 480 | }; 481 | /* End XCConfigurationList section */ 482 | }; 483 | rootObject = 9DB997E91D2CD29D0092AE25 /* Project object */; 484 | } 485 | --------------------------------------------------------------------------------