├── Pods ├── Target Support Files │ ├── Pods-SnapKit │ │ ├── Pods-SnapKit.xcconfig │ │ ├── Pods-SnapKit-prefix.pch │ │ ├── Pods-SnapKit.modulemap │ │ ├── Pods-SnapKit-dummy.m │ │ ├── Pods-SnapKit-umbrella.h │ │ ├── Pods-SnapKit-Private.xcconfig │ │ └── Info.plist │ └── Pods │ │ ├── Pods.modulemap │ │ ├── Pods-dummy.m │ │ ├── Pods-umbrella.h │ │ ├── Pods-environment.h │ │ ├── Pods.debug.xcconfig │ │ ├── Pods.release.xcconfig │ │ ├── Info.plist │ │ ├── Pods-acknowledgements.markdown │ │ ├── Pods-acknowledgements.plist │ │ ├── Pods-frameworks.sh │ │ └── Pods-resources.sh ├── Manifest.lock ├── Pods.xcodeproj │ └── xcuserdata │ │ └── humingtao.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ ├── Pods.xcscheme │ │ └── Pods-SnapKit.xcscheme └── SnapKit │ ├── LICENSE │ ├── Source │ ├── SnapKit.swift │ ├── ConstraintRelation.swift │ ├── EdgeInsets.swift │ ├── LayoutConstraint.swift │ ├── ConstraintItem.swift │ ├── Debugging.swift │ ├── ConstraintAttributes.swift │ ├── View+SnapKit.swift │ ├── ConstraintMaker.swift │ ├── Constraint.swift │ └── ConstraintDescription.swift │ └── README.md ├── code.png ├── Podfile ├── QRCodeByAVFoundation ├── Images.xcassets │ ├── line.imageset │ │ ├── line@2x.png │ │ ├── line@3x.png │ │ └── Contents.json │ ├── love.imageset │ │ ├── love@2x.png │ │ ├── love@3x.png │ │ └── Contents.json │ ├── cloud.imageset │ │ ├── cloud@2x.png │ │ ├── cloud@3x.png │ │ └── Contents.json │ ├── pick_bg.imageset │ │ ├── pick_bg@2x.png │ │ ├── pick_bg@3x.png │ │ └── Contents.json │ └── AppIcon.appiconset │ │ └── Contents.json ├── ViewController.swift ├── Info.plist ├── AppDelegate.swift ├── MyCodeViewController.swift ├── OverlayView.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard └── QRCodeViewController.swift ├── README.md ├── QRCodeByAVFoundation.xcworkspace ├── xcuserdata │ └── humingtao.xcuserdatad │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist └── contents.xcworkspacedata ├── Podfile.lock ├── QRCodeByAVFoundation.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcuserdata │ └── humingtao.xcuserdatad │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── QRCodeByAVFoundation.xcscheme └── project.pbxproj └── QRCodeByAVFoundationTests ├── Info.plist └── QRCodeByAVFoundationTests.swift /Pods/Target Support Files/Pods-SnapKit/Pods-SnapKit.xcconfig: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/code.png -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | platform :ios, '8.0' 3 | use_frameworks! 4 | 5 | pod 'SnapKit', '~> 0.10.0' -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SnapKit/Pods-SnapKit-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-environment.h" 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods { 2 | umbrella header "Pods-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods : NSObject 3 | @end 4 | @implementation PodsDummy_Pods 5 | @end 6 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/line.imageset/line@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/line.imageset/line@2x.png -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/line.imageset/line@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/line.imageset/line@3x.png -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/love.imageset/love@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/love.imageset/love@2x.png -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/love.imageset/love@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/love.imageset/love@3x.png -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SnapKit/Pods-SnapKit.modulemap: -------------------------------------------------------------------------------- 1 | framework module SnapKit { 2 | umbrella header "Pods-SnapKit-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/cloud.imageset/cloud@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/cloud.imageset/cloud@2x.png -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/cloud.imageset/cloud@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/cloud.imageset/cloud@3x.png -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double PodsVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char PodsVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/pick_bg.imageset/pick_bg@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/pick_bg.imageset/pick_bg@2x.png -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/pick_bg.imageset/pick_bg@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TommyFreya/QRCodeByAVFoundation/HEAD/QRCodeByAVFoundation/Images.xcassets/pick_bg.imageset/pick_bg@3x.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QRCodeByAVFoundation 2 | swift+avfoundation写的二维码扫描和生成Demo 3 | ![](http://7qn7zn.com1.z0.glb.clouddn.com/qrcode_1.PNG) 4 | ![](http://7qn7zn.com1.z0.glb.clouddn.com/qrcode_2.PNG) 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SnapKit/Pods-SnapKit-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_SnapKit : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_SnapKit 5 | @end 6 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation.xcworkspace/xcuserdata/humingtao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SnapKit (0.10.0) 3 | 4 | DEPENDENCIES: 5 | - SnapKit (~> 0.10.0) 6 | 7 | SPEC CHECKSUMS: 8 | SnapKit: 53696873f2cf84a15e8d7d0d9729ed4381196b16 9 | 10 | COCOAPODS: 0.36.4 11 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SnapKit (0.10.0) 3 | 4 | DEPENDENCIES: 5 | - SnapKit (~> 0.10.0) 6 | 7 | SPEC CHECKSUMS: 8 | SnapKit: 53696873f2cf84a15e8d7d0d9729ed4381196b16 9 | 10 | COCOAPODS: 0.36.4 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SnapKit/Pods-SnapKit-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double SnapKitVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char SnapKitVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/line.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "line@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "line@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/love.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "love@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "love@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/cloud.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "cloud@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "cloud@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.xcassets/pick_bg.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "pick_bg@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "pick_bg@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // SnapKit 10 | #define COCOAPODS_POD_AVAILABLE_SnapKit 11 | #define COCOAPODS_VERSION_MAJOR_SnapKit 0 12 | #define COCOAPODS_VERSION_MINOR_SnapKit 10 13 | #define COCOAPODS_VERSION_PATCH_SnapKit 0 14 | 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = "$PODS_FRAMEWORK_BUILD_PATH" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/SnapKit.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -framework "SnapKit" 6 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods 9 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = "$PODS_FRAMEWORK_BUILD_PATH" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/SnapKit.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -framework "SnapKit" 6 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods 9 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SnapKit/Pods-SnapKit-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-SnapKit.xcconfig" 2 | CONFIGURATION_BUILD_DIR = $PODS_FRAMEWORK_BUILD_PATH 3 | FRAMEWORK_SEARCH_PATHS = "$PODS_FRAMEWORK_BUILD_PATH" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SnapKit" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SnapKit" 6 | OTHER_LDFLAGS = -ObjC 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods 9 | PODS_ROOT = ${SRCROOT} 10 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /QRCodeByAVFoundation/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // QRCodeByAVFoundation 4 | // 5 | // Created by HMT on 15/5/20. 6 | // Copyright (c) 2015年 Tommy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | } 17 | 18 | override func viewDidAppear(animated: Bool) { 19 | super.viewDidAppear(animated) 20 | } 21 | 22 | override func didReceiveMemoryWarning() { 23 | super.didReceiveMemoryWarning() 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | } 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation.xcodeproj/xcuserdata/humingtao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | QRCodeByAVFoundation.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A78B459E1B0C2DB60090941F 16 | 17 | primary 18 | 19 | 20 | A78B45B31B0C2DB60090941F 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Images.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 | } -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/humingtao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-SnapKit.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 031846A7D4738593A6F76A5E 21 | 22 | primary 23 | 24 | 25 | C11F618593FEE5733FECAB25 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /QRCodeByAVFoundationTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.HMT.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SnapKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.10.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /QRCodeByAVFoundationTests/QRCodeByAVFoundationTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // QRCodeByAVFoundationTests.swift 3 | // QRCodeByAVFoundationTests 4 | // 5 | // Created by HMT on 15/5/20. 6 | // Copyright (c) 2015年 Tommy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class QRCodeByAVFoundationTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Pods/SnapKit/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## SnapKit 5 | 6 | Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - http://cocoapods.org 27 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.HMT.$(PRODUCT_NAME:rfc1034identifier) 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 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/SnapKit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | public typealias InterfaceLayoutDirection = UIUserInterfaceLayoutDirection 27 | #else 28 | import AppKit 29 | public typealias InterfaceLayoutDirection = NSUserInterfaceLayoutDirection 30 | #endif 31 | 32 | /** 33 | Used to configure different parts of SnapKit 34 | */ 35 | public struct Config { 36 | 37 | /// The interface layout direction 38 | public static var interfaceLayoutDirection = InterfaceLayoutDirection.LeftToRight 39 | 40 | } -------------------------------------------------------------------------------- /Pods/SnapKit/Source/ConstraintRelation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to define `NSLayoutRelation` 32 | */ 33 | internal enum ConstraintRelation: Int { 34 | case Equal = 1, LessThanOrEqualTo, GreaterThanOrEqualTo 35 | 36 | internal var layoutRelation: NSLayoutRelation { 37 | get { 38 | switch(self) { 39 | case .LessThanOrEqualTo: 40 | return .LessThanOrEqual 41 | case .GreaterThanOrEqualTo: 42 | return .GreaterThanOrEqual 43 | default: 44 | return .Equal 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Pods/SnapKit/Source/EdgeInsets.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | public typealias EdgeInsets = UIEdgeInsets 27 | public func EdgeInsetsMake(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> EdgeInsets { 28 | return EdgeInsets(top: top, left: left, bottom: bottom, right: right) 29 | } 30 | public let EdgeInsetsZero = EdgeInsets(top: 0, left: 0, bottom: 0, right: 0) 31 | #else 32 | import AppKit 33 | public typealias EdgeInsets = NSEdgeInsets 34 | public func EdgeInsetsMake(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> EdgeInsets { 35 | return EdgeInsets(top: top, left: left, bottom: bottom, right: right) 36 | } 37 | public let EdgeInsetsZero = EdgeInsets(top: 0, left: 0, bottom: 0, right: 0) 38 | #endif 39 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/humingtao.xcuserdatad/xcschemes/Pods.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | Title 38 | SnapKit 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - http://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/humingtao.xcuserdatad/xcschemes/Pods-SnapKit.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // QRCodeByAVFoundation 4 | // 5 | // Created by HMT on 15/5/20. 6 | // Copyright (c) 2015年 Tommy. 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 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/LayoutConstraint.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to add extra information to the actual `NSLayoutConstraint`'s that will UIKit/AppKit will utilize 32 | */ 33 | final public class LayoutConstraint: NSLayoutConstraint { 34 | 35 | internal var snp_constraint: Constraint? = nil 36 | 37 | } 38 | 39 | internal func ==(left: LayoutConstraint, right: LayoutConstraint) -> Bool { 40 | if left.firstItem !== right.firstItem { 41 | return false 42 | } 43 | if left.secondItem !== right.secondItem { 44 | return false 45 | } 46 | if left.firstAttribute != right.firstAttribute { 47 | return false 48 | } 49 | if left.secondAttribute != right.secondAttribute { 50 | return false 51 | } 52 | if left.relation != right.relation { 53 | return false 54 | } 55 | if left.priority != right.priority { 56 | return false 57 | } 58 | if left.multiplier != right.multiplier { 59 | return false 60 | } 61 | return true 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/ConstraintItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to assist in building a constraint 32 | */ 33 | final public class ConstraintItem { 34 | 35 | internal init(object: AnyObject?, attributes: ConstraintAttributes) { 36 | self.object = object 37 | self.attributes = attributes 38 | } 39 | 40 | internal weak var object: AnyObject? 41 | internal var attributes: ConstraintAttributes 42 | 43 | internal var view: View? { 44 | return self.object as? View 45 | } 46 | 47 | #if os(iOS) 48 | 49 | internal var layoutSupport: UILayoutSupport? { 50 | return self.object as? UILayoutSupport 51 | } 52 | 53 | #endif 54 | } 55 | 56 | 57 | internal func ==(left: ConstraintItem, right: ConstraintItem) -> Bool { 58 | if left.object == nil { 59 | return false 60 | } 61 | if right.object == nil { 62 | return false 63 | } 64 | if left.object !== right.object { 65 | return false 66 | } 67 | if left.attributes != right.attributes { 68 | return false 69 | } 70 | return true 71 | } -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | local source="${BUILT_PRODUCTS_DIR}/Pods/$1" 12 | local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 13 | 14 | if [ -L "${source}" ]; then 15 | echo "Symlinked..." 16 | source=$(readlink "${source}") 17 | fi 18 | 19 | # use filter instead of exclude so missing patterns dont' throw errors 20 | echo "rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers/" --filter "- PrivateHeaders/" ${source} ${destination}" 21 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers/" --filter "- PrivateHeaders/" "${source}" "${destination}" 22 | # Resign the code if required by the build settings to avoid unstable apps 23 | if [ "${CODE_SIGNING_REQUIRED}" == "YES" ]; then 24 | code_sign "${destination}/$1" 25 | fi 26 | 27 | # Embed linked Swift runtime libraries 28 | local basename 29 | basename=$(echo $1 | sed -E s/\\..+// && exit ${PIPESTATUS[0]}) 30 | local swift_runtime_libs 31 | swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/$1/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 32 | for lib in $swift_runtime_libs; do 33 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 34 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 35 | if [ "${CODE_SIGNING_REQUIRED}" == "YES" ]; then 36 | code_sign "${destination}/${lib}" 37 | fi 38 | done 39 | } 40 | 41 | # Signs a framework with the provided identity 42 | code_sign() { 43 | # Use the current code_sign_identitiy 44 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 45 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements $1" 46 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 47 | } 48 | 49 | 50 | if [[ "$CONFIGURATION" == "Debug" ]]; then 51 | install_framework 'SnapKit.framework' 52 | fi 53 | if [[ "$CONFIGURATION" == "Release" ]]; then 54 | install_framework 'SnapKit.framework' 55 | fi 56 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/MyCodeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyCodeViewController.swift 3 | // QRCodeByAVFoundation 4 | // 5 | // Created by HMT on 15/6/1. 6 | // Copyright (c) 2015年 Tommy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MyCodeViewController: UIViewController { 12 | 13 | @IBOutlet weak var textStrTextField: UITextField! 14 | @IBOutlet weak var imageNameTextField: UITextField! 15 | @IBOutlet weak var qrCodeImageView: UIImageView! 16 | 17 | // MARK: - Life Cycle 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | } 21 | 22 | // MARK: - Event Action 23 | override func touchesBegan(touches: Set, withEvent event: UIEvent) { 24 | self.view.endEditing(true) 25 | } 26 | 27 | @IBAction func clickCreateQrCodeAction(sender: UIButton) { 28 | qrCodeImageView.image = createQRForString(textStrTextField.text, qrImageName: imageNameTextField.text) 29 | } 30 | 31 | // MARK: - Private Methods 32 | private func createQRForString(qrString: String?, qrImageName: String?) -> UIImage?{ 33 | if let sureQRString = qrString { 34 | let stringData = sureQRString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) 35 | // 创建一个二维码的滤镜 36 | let qrFilter = CIFilter(name: "CIQRCodeGenerator") 37 | qrFilter.setValue(stringData, forKey: "inputMessage") 38 | qrFilter.setValue("H", forKey: "inputCorrectionLevel") 39 | let qrCIImage = qrFilter.outputImage 40 | // 创建一个颜色滤镜,黑白色 41 | let colorFilter = CIFilter(name: "CIFalseColor") 42 | colorFilter.setDefaults() 43 | colorFilter.setValue(qrCIImage, forKey: "inputImage") 44 | colorFilter.setValue(CIColor(red: 0, green: 0, blue: 0), forKey: "inputColor0") 45 | colorFilter.setValue(CIColor(red: 1, green: 1, blue: 1), forKey: "inputColor1") 46 | // 返回二维码image 47 | let codeImage = UIImage(CIImage: colorFilter.outputImage.imageByApplyingTransform(CGAffineTransformMakeScale(5, 5))) 48 | // 通常,二维码都是定制的,中间都会放想要表达意思的图片 49 | if let iconImage = UIImage(named: qrImageName!) { 50 | let rect = CGRectMake(0, 0, codeImage!.size.width, codeImage!.size.height) 51 | UIGraphicsBeginImageContext(rect.size) 52 | 53 | codeImage!.drawInRect(rect) 54 | let avatarSize = CGSizeMake(rect.size.width * 0.25, rect.size.height * 0.25) 55 | let x = (rect.width - avatarSize.width) * 0.5 56 | let y = (rect.height - avatarSize.height) * 0.5 57 | iconImage.drawInRect(CGRectMake(x, y, avatarSize.width, avatarSize.height)) 58 | let resultImage = UIGraphicsGetImageFromCurrentImageContext() 59 | 60 | UIGraphicsEndImageContext() 61 | return resultImage 62 | } 63 | return codeImage 64 | } 65 | return nil 66 | } 67 | 68 | override func didReceiveMemoryWarning() { 69 | super.didReceiveMemoryWarning() 70 | // Dispose of any resources that can be recreated. 71 | } 72 | 73 | } 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/OverlayView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OverlayView.swift 3 | // QRCodeByAVFoundation 4 | // 5 | // Created by HMT on 15/5/21. 6 | // Copyright (c) 2015年 Tommy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SnapKit 11 | 12 | class OverlayView: UIView { 13 | 14 | var codeView: UIImageView! 15 | private var messageLabel: UILabel! 16 | var myCodeButton: UIButton! 17 | var scrollLabel: UIImageView! 18 | var clickCodeButtonClosure: dispatch_block_t? 19 | 20 | override init(frame: CGRect) { 21 | super.init(frame:frame) 22 | setUpCustomView() 23 | self.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.2) 24 | } 25 | 26 | private func setUpCustomView() { 27 | codeView = { 28 | let imageView = UIImageView() 29 | imageView.image = UIImage(named: "pick_bg") 30 | self.addSubview(imageView) 31 | imageView.snp_makeConstraints{ (make) -> Void in 32 | make.top.equalTo(imageView.superview!.snp_top).offset(64+64) 33 | make.height.width.equalTo(280) 34 | make.centerX.equalTo(imageView.superview!.snp_centerX) 35 | } 36 | return imageView 37 | }() 38 | 39 | messageLabel = { 40 | let label = UILabel() 41 | label.text = "将二维码放入框内,即可自动扫描" 42 | label.textColor = UIColor.whiteColor() 43 | label.font = UIFont.systemFontOfSize(13.0) 44 | self.addSubview(label) 45 | label.snp_makeConstraints{ (make) -> Void in 46 | make.top.equalTo(self.codeView.snp_bottom).offset(10) 47 | make.centerX.equalTo(label.superview!.snp_centerX) 48 | make.height.equalTo(15) 49 | } 50 | return label 51 | }() 52 | 53 | scrollLabel = { 54 | let imageView = UIImageView() 55 | imageView.image = UIImage(named: "line") 56 | imageView.hidden = true 57 | self.addSubview(imageView) 58 | imageView.snp_makeConstraints{ (make) -> Void in 59 | make.width.equalTo(220) 60 | make.top.equalTo(self.codeView.snp_top) 61 | make.centerX.equalTo(imageView.superview!.snp_centerX) 62 | make.height.equalTo(5) 63 | } 64 | return imageView 65 | }() 66 | 67 | myCodeButton = { 68 | let button = UIButton.buttonWithType(.System) as! UIButton 69 | button.setTitle("我的二维码", forState: .Normal) 70 | button.setTitleColor(UIColor.greenColor(), forState: .Normal) 71 | button.addTarget(self, action: Selector("didClickCreateSelfCodeAction:"), forControlEvents: .TouchUpInside) 72 | self.addSubview(button) 73 | button.snp_makeConstraints{ (make) -> Void in 74 | make.top.equalTo(self.messageLabel.snp_bottom).offset(15) 75 | make.centerX.equalTo(button.superview!.snp_centerX) 76 | make.height.equalTo(30) 77 | } 78 | return button 79 | }() 80 | } 81 | 82 | func didClickCreateSelfCodeAction(btn: UIButton) { 83 | if let sureClosure = clickCodeButtonClosure { 84 | sureClosure() 85 | } 86 | } 87 | 88 | required init(coder aDecoder: NSCoder) { 89 | fatalError("init(coder:) has not been implemented") 90 | } 91 | 92 | } 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods/Pods-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY=$(cd "${1%/*}" && pwd) 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | 61 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 62 | if [[ "${ACTION}" == "install" ]]; then 63 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 64 | fi 65 | rm -f "$RESOURCES_TO_COPY" 66 | 67 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 68 | then 69 | case "${TARGETED_DEVICE_FAMILY}" in 70 | 1,2) 71 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 72 | ;; 73 | 1) 74 | TARGET_DEVICE_ARGS="--target-device iphone" 75 | ;; 76 | 2) 77 | TARGET_DEVICE_ARGS="--target-device ipad" 78 | ;; 79 | *) 80 | TARGET_DEVICE_ARGS="--target-device mac" 81 | ;; 82 | esac 83 | 84 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 85 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 86 | while read line; do 87 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 88 | XCASSET_FILES+=("$line") 89 | fi 90 | done <<<"$OTHER_XCASSETS" 91 | 92 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 93 | fi 94 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation.xcodeproj/xcuserdata/humingtao.xcuserdatad/xcschemes/QRCodeByAVFoundation.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/Debugging.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to allow adding a snp_label to a View for debugging purposes 32 | */ 33 | public extension View { 34 | 35 | public var snp_label: String? { 36 | get { 37 | return objc_getAssociatedObject(self, &labelKey) as? String 38 | } 39 | set { 40 | objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_COPY_NONATOMIC)) 41 | } 42 | } 43 | 44 | } 45 | 46 | /** 47 | Used to allow adding a snp_label to a LayoutConstraint for debugging purposes 48 | */ 49 | public extension LayoutConstraint { 50 | 51 | public var snp_label: String? { 52 | get { 53 | return objc_getAssociatedObject(self, &labelKey) as? String 54 | } 55 | set { 56 | objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_COPY_NONATOMIC)) 57 | } 58 | } 59 | 60 | override public var description: String { 61 | var description = "<" 62 | 63 | description += descriptionForObject(self) 64 | 65 | description += " \(descriptionForObject(self.firstItem))" 66 | if self.firstAttribute != .NotAnAttribute { 67 | description += ".\(self.firstAttribute.snp_description)" 68 | } 69 | 70 | description += " \(self.relation.snp_description)" 71 | 72 | if let secondItem: AnyObject = self.secondItem { 73 | description += " \(descriptionForObject(secondItem))" 74 | } 75 | 76 | if self.secondAttribute != .NotAnAttribute { 77 | description += ".\(self.secondAttribute.snp_description)" 78 | } 79 | 80 | if self.multiplier != 1.0 { 81 | description += " * \(self.multiplier)" 82 | } 83 | 84 | if self.secondAttribute == .NotAnAttribute { 85 | description += " \(self.constant)" 86 | } else { 87 | if self.constant > 0.0 { 88 | description += " + \(self.constant)" 89 | } else if self.constant < 0.0 { 90 | description += " - \(CGFloat.abs(self.constant))" 91 | } 92 | } 93 | 94 | if self.priority != 1000.0 { 95 | description += " ^\(self.priority)" 96 | } 97 | 98 | description += ">" 99 | 100 | return description 101 | } 102 | 103 | } 104 | 105 | private var labelKey = "" 106 | 107 | private func descriptionForObject(object: AnyObject) -> String { 108 | let pointerDescription = NSString(format: "%p", [object]) 109 | if let object = object as? View { 110 | return "<\(object.dynamicType):\(object.snp_label ?? pointerDescription)>" 111 | } else if let object = object as? LayoutConstraint { 112 | return "<\(object.dynamicType):\(object.snp_label ?? pointerDescription)>" 113 | } 114 | return "<\(object.dynamicType):\(pointerDescription)>" 115 | } 116 | 117 | private extension NSLayoutRelation { 118 | 119 | private var snp_description: String { 120 | switch self { 121 | case .Equal: return "==" 122 | case .GreaterThanOrEqual: return ">=" 123 | case .LessThanOrEqual: return "<=" 124 | } 125 | } 126 | 127 | } 128 | 129 | private extension NSLayoutAttribute { 130 | 131 | private var snp_description: String { 132 | #if os(iOS) 133 | switch self { 134 | case .NotAnAttribute: return "notAnAttribute" 135 | case .Top: return "top" 136 | case .Left: return "left" 137 | case .Bottom: return "bottom" 138 | case .Right: return "right" 139 | case .Leading: return "leading" 140 | case .Trailing: return "trailing" 141 | case .Width: return "width" 142 | case .Height: return "height" 143 | case .CenterX: return "centerX" 144 | case .CenterY: return "centerY" 145 | case .Baseline: return "baseline" 146 | case .FirstBaseline: return "firstBaseline" 147 | case .TopMargin: return "topMargin" 148 | case .LeftMargin: return "leftMargin" 149 | case .BottomMargin: return "bottomMargin" 150 | case .RightMargin: return "rightMargin" 151 | case .LeadingMargin: return "leadingMargin" 152 | case .TrailingMargin: return "trailingMargin" 153 | case .CenterXWithinMargins: return "centerXWithinMargins" 154 | case .CenterYWithinMargins: return "centerYWithinMargins" 155 | } 156 | #else 157 | switch self { 158 | case .NotAnAttribute: return "notAnAttribute" 159 | case .Top: return "top" 160 | case .Left: return "left" 161 | case .Bottom: return "bottom" 162 | case .Right: return "right" 163 | case .Leading: return "leading" 164 | case .Trailing: return "trailing" 165 | case .Width: return "width" 166 | case .Height: return "height" 167 | case .CenterX: return "centerX" 168 | case .CenterY: return "centerY" 169 | case .Baseline: return "baseline" 170 | } 171 | #endif 172 | 173 | } 174 | 175 | } 176 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/ConstraintAttributes.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to define `NSLayoutAttributes` in a more concise and composite manner 32 | */ 33 | internal struct ConstraintAttributes: RawOptionSetType, BooleanType { 34 | 35 | internal init(rawValue: UInt) { 36 | self.rawValue = rawValue 37 | } 38 | internal init(_ rawValue: UInt) { 39 | self.init(rawValue: rawValue) 40 | } 41 | internal init(nilLiteral: ()) { 42 | self.rawValue = 0 43 | } 44 | 45 | internal private(set) var rawValue: UInt 46 | internal static var allZeros: ConstraintAttributes { return self(0) } 47 | internal static func convertFromNilLiteral() -> ConstraintAttributes { return self(0) } 48 | internal var boolValue: Bool { return self.rawValue != 0 } 49 | 50 | internal func toRaw() -> UInt { return self.rawValue } 51 | internal static func fromRaw(raw: UInt) -> ConstraintAttributes? { return self(raw) } 52 | internal static func fromMask(raw: UInt) -> ConstraintAttributes { return self(raw) } 53 | 54 | // normal 55 | 56 | internal static var None: ConstraintAttributes { return self(0) } 57 | internal static var Left: ConstraintAttributes { return self(1) } 58 | internal static var Top: ConstraintAttributes { return self(2) } 59 | internal static var Right: ConstraintAttributes { return self(4) } 60 | internal static var Bottom: ConstraintAttributes { return self(8) } 61 | internal static var Leading: ConstraintAttributes { return self(16) } 62 | internal static var Trailing: ConstraintAttributes { return self(32) } 63 | internal static var Width: ConstraintAttributes { return self(64) } 64 | internal static var Height: ConstraintAttributes { return self(128) } 65 | internal static var CenterX: ConstraintAttributes { return self(256) } 66 | internal static var CenterY: ConstraintAttributes { return self(512) } 67 | internal static var Baseline: ConstraintAttributes { return self(1024) } 68 | 69 | #if os(iOS) 70 | internal static var FirstBaseline: ConstraintAttributes { return self(2048) } 71 | internal static var LeftMargin: ConstraintAttributes { return self(4096) } 72 | internal static var RightMargin: ConstraintAttributes { return self(8192) } 73 | internal static var TopMargin: ConstraintAttributes { return self(16384) } 74 | internal static var BottomMargin: ConstraintAttributes { return self(32768) } 75 | internal static var LeadingMargin: ConstraintAttributes { return self(65536) } 76 | internal static var TrailingMargin: ConstraintAttributes { return self(131072) } 77 | internal static var CenterXWithinMargins: ConstraintAttributes { return self(262144) } 78 | internal static var CenterYWithinMargins: ConstraintAttributes { return self(524288) } 79 | #endif 80 | 81 | // aggregates 82 | 83 | internal static var Edges: ConstraintAttributes { return self(15) } 84 | internal static var Size: ConstraintAttributes { return self(192) } 85 | internal static var Center: ConstraintAttributes { return self(768) } 86 | 87 | #if os(iOS) 88 | internal static var Margins: ConstraintAttributes { return self(61440) } 89 | internal static var CenterWithinMargins: ConstraintAttributes { return self(786432) } 90 | #endif 91 | 92 | internal var layoutAttributes:[NSLayoutAttribute] { 93 | var attrs = [NSLayoutAttribute]() 94 | if (self & ConstraintAttributes.Left) { 95 | attrs.append(.Left) 96 | } 97 | if (self & ConstraintAttributes.Top) { 98 | attrs.append(.Top) 99 | } 100 | if (self & ConstraintAttributes.Right) { 101 | attrs.append(.Right) 102 | } 103 | if (self & ConstraintAttributes.Bottom) { 104 | attrs.append(.Bottom) 105 | } 106 | if (self & ConstraintAttributes.Leading) { 107 | attrs.append(.Leading) 108 | } 109 | if (self & ConstraintAttributes.Trailing) { 110 | attrs.append(.Trailing) 111 | } 112 | if (self & ConstraintAttributes.Width) { 113 | attrs.append(.Width) 114 | } 115 | if (self & ConstraintAttributes.Height) { 116 | attrs.append(.Height) 117 | } 118 | if (self & ConstraintAttributes.CenterX) { 119 | attrs.append(.CenterX) 120 | } 121 | if (self & ConstraintAttributes.CenterY) { 122 | attrs.append(.CenterY) 123 | } 124 | if (self & ConstraintAttributes.Baseline) { 125 | attrs.append(.Baseline) 126 | } 127 | #if os(iOS) 128 | if (self & ConstraintAttributes.FirstBaseline) { 129 | attrs.append(.FirstBaseline) 130 | } 131 | if (self & ConstraintAttributes.LeftMargin) { 132 | attrs.append(.LeftMargin) 133 | } 134 | if (self & ConstraintAttributes.RightMargin) { 135 | attrs.append(.RightMargin) 136 | } 137 | if (self & ConstraintAttributes.TopMargin) { 138 | attrs.append(.TopMargin) 139 | } 140 | if (self & ConstraintAttributes.BottomMargin) { 141 | attrs.append(.BottomMargin) 142 | } 143 | if (self & ConstraintAttributes.LeadingMargin) { 144 | attrs.append(.LeadingMargin) 145 | } 146 | if (self & ConstraintAttributes.TrailingMargin) { 147 | attrs.append(.TrailingMargin) 148 | } 149 | if (self & ConstraintAttributes.CenterXWithinMargins) { 150 | attrs.append(.CenterXWithinMargins) 151 | } 152 | if (self & ConstraintAttributes.CenterYWithinMargins) { 153 | attrs.append(.CenterYWithinMargins) 154 | } 155 | #endif 156 | return attrs 157 | } 158 | } 159 | internal func +=(inout left: ConstraintAttributes, right: ConstraintAttributes) { 160 | left = (left | right) 161 | } 162 | internal func -=(inout left: ConstraintAttributes, right: ConstraintAttributes) { 163 | left = left & ~right 164 | } 165 | internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool { 166 | return left.rawValue == right.rawValue 167 | } 168 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/QRCodeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // QRCodeViewController.swift 3 | // QRCodeByAVFoundation 4 | // 5 | // Created by HMT on 15/5/21. 6 | // Copyright (c) 2015年 Tommy. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVFoundation 11 | import SnapKit 12 | 13 | struct ScreenWH { 14 | static let screenWidth = UIScreen.mainScreen().bounds.size.width 15 | static let screenHeight = UIScreen.mainScreen().bounds.size.height 16 | } 17 | 18 | class QRCodeViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate { 19 | 20 | var captureSession: AVCaptureSession? 21 | var videoPreviewLayer: AVCaptureVideoPreviewLayer? 22 | var captureView: UIView! 23 | var qrcodeView: OverlayView! 24 | var timer: NSTimer? 25 | 26 | // MARK: - Life Cycle 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | // 消除导航栏返回自带的数字 31 | UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), forBarMetrics: .Default) 32 | 33 | initCapture() 34 | setupCaptureView() 35 | if let goodSession = captureSession { 36 | // 启动 37 | goodSession.startRunning() 38 | timer = NSTimer.scheduledTimerWithTimeInterval(2.0, target: self, selector: Selector("scrollScanAction"), userInfo: nil, repeats: true) 39 | } 40 | } 41 | 42 | override func viewDidDisappear(animated: Bool) { 43 | super.viewDidDisappear(animated) 44 | if let sureTimer = timer { 45 | sureTimer.invalidate() 46 | } 47 | } 48 | 49 | // MARK: - View Setup 50 | private func setupCaptureView() { 51 | // 创建系统自动捕获框 52 | captureView = { 53 | let captureView = UIView() 54 | captureView.layer.borderColor = UIColor.greenColor().CGColor 55 | captureView.layer.borderWidth = 2 56 | self.view.addSubview(captureView) 57 | self.view.bringSubviewToFront(captureView) 58 | return captureView 59 | }() 60 | // 扫一扫的图片 61 | qrcodeView = { 62 | let codeView = OverlayView(frame: CGRectZero) 63 | codeView.clickCodeButtonClosure = { 64 | let myCodeVC = self.storyboard!.instantiateViewControllerWithIdentifier("MyCodeViewController") as! MyCodeViewController 65 | self.navigationController!.pushViewController(myCodeVC, animated: true) 66 | } 67 | self.view.addSubview(codeView) 68 | self.view.bringSubviewToFront(self.captureView) 69 | codeView.snp_makeConstraints{ (make) -> Void in 70 | make.edges.equalTo(self.view) 71 | } 72 | return codeView 73 | }() 74 | } 75 | 76 | // MARK: - Private Methods 77 | // 初始化视频捕获 78 | private func initCapture() { 79 | // 代表抽象的硬件设备,这里传入video 80 | let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) 81 | var error: NSError? 82 | // 输入流 83 | var captureInput = AVCaptureDeviceInput.deviceInputWithDevice(captureDevice, error: &error) as? AVCaptureDeviceInput 84 | if (error != nil && captureInput == nil) { 85 | let errorAlert = UIAlertController(title: "提醒", message: "请在iPhone的\"设置-隐私-相机\"选项中,允许XXX访问您的相机", preferredStyle: .Alert) 86 | errorAlert.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Default, handler: nil)) 87 | self.presentViewController(errorAlert, animated: true, completion: nil) 88 | } else { 89 | // input和output的桥梁,它协调着intput到output的数据传输.(见字意,session-会话) 90 | captureSession = AVCaptureSession() 91 | captureSession!.addInput(captureInput) 92 | 93 | // 输出流 94 | let captureMetadataOutput = AVCaptureMetadataOutput() 95 | // 限制扫描区域http://blog.csdn.net/lc_obj/article/details/41549469 96 | captureMetadataOutput.rectOfInterest = CGRectMake(128.0/ScreenWH.screenHeight, (ScreenWH.screenWidth - 280.0)/ScreenWH.screenWidth * 2.0, 280.0/ScreenWH.screenHeight, 280.0/ScreenWH.screenWidth) 97 | captureSession!.addOutput(captureMetadataOutput) 98 | // 添加的队列按规定必须是串行 99 | captureMetadataOutput.setMetadataObjectsDelegate(self, queue: dispatch_get_main_queue()) 100 | // 指定信息类型,QRCode,你懂的 101 | captureMetadataOutput.metadataObjectTypes = [AVMetadataObjectTypeQRCode] 102 | 103 | // 用这个预览图层和图像信息捕获会话(session)来显示视频 104 | videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession!) 105 | videoPreviewLayer!.videoGravity = AVLayerVideoGravityResizeAspectFill 106 | videoPreviewLayer!.frame = view.bounds 107 | view.layer.addSublayer(videoPreviewLayer!) 108 | } 109 | } 110 | // 关闭捕获 111 | private func stopCapture() { 112 | captureSession!.startRunning() 113 | captureView.removeFromSuperview() 114 | self.navigationController!.popViewControllerAnimated(true) 115 | } 116 | 117 | // MARK: - AVCaptureMetadataOutputObjectsDelegate 118 | func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) { 119 | if metadataObjects == nil || metadataObjects.count == 0 { 120 | captureView!.frame = CGRectZero 121 | return 122 | } 123 | // 刷取出来的数据 124 | for metadataObject in metadataObjects { 125 | if metadataObject.type == AVMetadataObjectTypeQRCode { 126 | let metadata = metadataObject as! AVMetadataMachineReadableCodeObject 127 | // 元数据对象就会被转化成图层的坐标 128 | let codeCoord = videoPreviewLayer!.transformedMetadataObjectForMetadataObject(metadata) as! AVMetadataMachineReadableCodeObject 129 | captureView!.frame = codeCoord.bounds 130 | if metadata.stringValue != nil { 131 | println("\(metadata.stringValue)") 132 | self.captureSession!.stopRunning() 133 | let successAlert = UIAlertController(title:"提示", message:"是否打开" + metadata.stringValue, preferredStyle: .Alert) 134 | successAlert.addAction(UIAlertAction(title:"取消", style: .Default, handler: { (_) -> Void in 135 | self.stopCapture() 136 | })) 137 | successAlert.addAction(UIAlertAction(title:"确定", style: .Default, handler: { (_) -> Void in 138 | if metadata.stringValue.lowercaseString.hasPrefix("http") { 139 | UIApplication.sharedApplication().openURL(NSURL(string: metadata.stringValue)!) 140 | self.navigationController!.popViewControllerAnimated(true) 141 | } 142 | })) 143 | self.presentViewController(successAlert, animated: true, completion: nil) 144 | } 145 | } 146 | } 147 | } 148 | 149 | // MARK: - Event Actions 150 | // 定时器控制扫描控件 151 | func scrollScanAction() { 152 | qrcodeView.scrollLabel.hidden = false 153 | qrcodeView.scrollLabel.snp_updateConstraints { (make) -> Void in 154 | // error,因为supdate只能更新原有约束的值,并不能加入新的约束 155 | // make.bottom.equalTo(self.qrcodeView.codeView.snp_bottom).offset(-10) 156 | make.top.equalTo(self.qrcodeView.codeView.snp_top).offset(270) 157 | } 158 | UIView.animateWithDuration(1.9, animations: { () -> Void in 159 | self.view.layoutIfNeeded() 160 | }) { (_) -> Void in 161 | self.qrcodeView.scrollLabel.snp_updateConstraints { (make) -> Void in 162 | make.top.equalTo(self.qrcodeView.codeView.snp_top).offset(5) 163 | } 164 | } 165 | } 166 | 167 | override func didReceiveMemoryWarning() { 168 | super.didReceiveMemoryWarning() 169 | // Dispose of any resources that can be recreated. 170 | } 171 | 172 | //..... 173 | /* 174 | // MARK: - Navigation 175 | 176 | // In a storyboard-based application, you will often want to do a little preparation before navigation 177 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 178 | // Get the new view controller using segue.destinationViewController. 179 | // Pass the selected object to the new view controller. 180 | } 181 | */ 182 | 183 | } 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/View+SnapKit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | public typealias View = UIView 27 | #else 28 | import AppKit 29 | public typealias View = NSView 30 | #endif 31 | 32 | /** 33 | Used to expose public API on views 34 | */ 35 | public extension View { 36 | 37 | /// left edge 38 | final public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) } 39 | 40 | /// top edge 41 | final public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) } 42 | 43 | /// right edge 44 | final public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) } 45 | 46 | /// bottom edge 47 | final public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) } 48 | 49 | /// leading edge 50 | final public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) } 51 | 52 | /// trailing edge 53 | final public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) } 54 | 55 | /// width dimension 56 | final public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) } 57 | 58 | /// height dimension 59 | final public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) } 60 | 61 | /// centerX position 62 | final public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) } 63 | 64 | /// centerY position 65 | final public var snp_centerY: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterY) } 66 | 67 | /// baseline position 68 | final public var snp_baseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Baseline) } 69 | 70 | #if os(iOS) 71 | 72 | /// first baseline position 73 | final public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) } 74 | 75 | /// left margin 76 | final public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) } 77 | 78 | /// right margin 79 | final public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) } 80 | 81 | /// top margin 82 | final public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) } 83 | 84 | /// bottom margin 85 | final public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) } 86 | 87 | /// leading margin 88 | final public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) } 89 | 90 | /// trailing margin 91 | final public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) } 92 | 93 | /// centerX within margins 94 | final public var snp_centerXWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterXWithinMargins) } 95 | 96 | /// centerY within margins 97 | final public var snp_centerYWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterYWithinMargins) } 98 | 99 | #endif 100 | 101 | // top + left + bottom + right edges 102 | final public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) } 103 | 104 | // width + height dimensions 105 | final public var snp_size: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Size) } 106 | 107 | // centerX + centerY positions 108 | final public var snp_center: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Center) } 109 | 110 | #if os(iOS) 111 | 112 | // top + left + bottom + right margins 113 | final public var snp_margins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Margins) } 114 | 115 | // centerX + centerY within margins 116 | final public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) } 117 | 118 | #endif 119 | 120 | /** 121 | Prepares constraints with a `ConstraintMaker` and returns the made constraints but does not install them. 122 | 123 | :param: closure that will be passed the `ConstraintMaker` to make the constraints with 124 | 125 | :returns: the constraints made 126 | */ 127 | final public func snp_prepareConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] { 128 | return ConstraintMaker.prepareConstraints(self, closure: closure) 129 | } 130 | 131 | /** 132 | Makes constraints with a `ConstraintMaker` and installs them along side any previous made constraints. 133 | 134 | :param: closure that will be passed the `ConstraintMaker` to make the constraints with 135 | */ 136 | final public func snp_makeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void { 137 | ConstraintMaker.makeConstraints(self, closure: closure) 138 | } 139 | 140 | /** 141 | Updates constraints with a `ConstraintMaker` that will replace existing constraints that match and install new ones. 142 | 143 | For constraints to match only the constant can be updated. 144 | 145 | :param: closure that will be passed the `ConstraintMaker` to update the constraints with 146 | */ 147 | final public func snp_updateConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void { 148 | ConstraintMaker.updateConstraints(self, closure: closure) 149 | } 150 | 151 | /** 152 | Remakes constraints with a `ConstraintMaker` that will first remove all previously made constraints and make and install new ones. 153 | 154 | :param: closure that will be passed the `ConstraintMaker` to remake the constraints with 155 | */ 156 | final public func snp_remakeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void { 157 | ConstraintMaker.remakeConstraints(self, closure: closure) 158 | } 159 | 160 | /** 161 | Removes all previously made constraints. 162 | */ 163 | final public func snp_removeConstraints() { 164 | ConstraintMaker.removeConstraints(self) 165 | } 166 | 167 | final internal var snp_installedLayoutConstraints: [LayoutConstraint] { 168 | get { 169 | if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? [LayoutConstraint] { 170 | return constraints 171 | } 172 | return [] 173 | } 174 | set { 175 | objc_setAssociatedObject(self, &installedLayoutConstraintsKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) 176 | } 177 | } 178 | } 179 | 180 | private var installedLayoutConstraintsKey = "" 181 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/ConstraintMaker.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to make constraints 32 | */ 33 | final public class ConstraintMaker { 34 | 35 | /// left edge 36 | public var left: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Left) } 37 | 38 | /// top edge 39 | public var top: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Top) } 40 | 41 | /// right edge 42 | public var right: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Right) } 43 | 44 | /// bottom edge 45 | public var bottom: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Bottom) } 46 | 47 | /// leading edge 48 | public var leading: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Leading) } 49 | 50 | /// trailing edge 51 | public var trailing: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Trailing) } 52 | 53 | /// width dimension 54 | public var width: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Width) } 55 | 56 | /// height dimension 57 | public var height: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Height) } 58 | 59 | /// centerX dimension 60 | public var centerX: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterX) } 61 | 62 | /// centerY dimension 63 | public var centerY: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterY) } 64 | 65 | /// baseline position 66 | public var baseline: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Baseline) } 67 | 68 | #if os(iOS) 69 | 70 | /// firse baseline position 71 | public var firstBaseline: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.FirstBaseline) } 72 | 73 | /// left margin 74 | public var leftMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.LeftMargin) } 75 | 76 | /// right margin 77 | public var rightMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.RightMargin) } 78 | 79 | /// top margin 80 | public var topMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.TopMargin) } 81 | 82 | /// bottom margin 83 | public var bottomMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.BottomMargin) } 84 | 85 | /// leading margin 86 | public var leadingMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.LeadingMargin) } 87 | 88 | /// trailing margin 89 | public var trailingMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.TrailingMargin) } 90 | 91 | /// centerX within margins 92 | public var centerXWithinMargins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterXWithinMargins) } 93 | 94 | /// centerY within margins 95 | public var centerYWithinMargins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterYWithinMargins) } 96 | #endif 97 | 98 | /// top + left + bottom + right edges 99 | public var edges: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Edges) } 100 | 101 | /// width + height dimensions 102 | public var size: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Size) } 103 | 104 | // centerX + centerY positions 105 | public var center: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Center) } 106 | 107 | #if os(iOS) 108 | 109 | // top + left + bottom + right margins 110 | public var snp_margins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Margins) } 111 | 112 | // centerX + centerY within margins 113 | public var snp_centerWithinMargins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterWithinMargins) } 114 | 115 | #endif 116 | 117 | internal init(view: View) { 118 | self.view = view 119 | } 120 | 121 | internal let view: View 122 | internal var constraintDescriptions = [ConstraintDescription]() 123 | 124 | internal func makeConstraintDescription(attributes: ConstraintAttributes) -> ConstraintDescription { 125 | let item = ConstraintItem(object: self.view, attributes: attributes) 126 | let constraintDescription = ConstraintDescription(fromItem: item) 127 | self.constraintDescriptions.append(constraintDescription) 128 | return constraintDescription 129 | } 130 | 131 | internal class func prepareConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] { 132 | let maker = ConstraintMaker(view: view) 133 | closure(make: maker) 134 | 135 | return maker.constraintDescriptions.map { $0.constraint } 136 | } 137 | 138 | internal class func makeConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) { 139 | #if os(iOS) 140 | view.setTranslatesAutoresizingMaskIntoConstraints(false) 141 | #else 142 | view.translatesAutoresizingMaskIntoConstraints = false 143 | #endif 144 | let maker = ConstraintMaker(view: view) 145 | closure(make: maker) 146 | 147 | let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint } 148 | for constraint in constraints { 149 | constraint.installOnView(updateExisting: false) 150 | } 151 | } 152 | 153 | internal class func remakeConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) { 154 | #if os(iOS) 155 | view.setTranslatesAutoresizingMaskIntoConstraints(false) 156 | #else 157 | view.translatesAutoresizingMaskIntoConstraints = false 158 | #endif 159 | let maker = ConstraintMaker(view: view) 160 | closure(make: maker) 161 | 162 | self.removeConstraints(view) 163 | let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint } 164 | for constraint in constraints { 165 | constraint.installOnView(updateExisting: false) 166 | } 167 | } 168 | 169 | internal class func updateConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) { 170 | #if os(iOS) 171 | view.setTranslatesAutoresizingMaskIntoConstraints(false) 172 | #else 173 | view.translatesAutoresizingMaskIntoConstraints = false 174 | #endif 175 | let maker = ConstraintMaker(view: view) 176 | closure(make: maker) 177 | 178 | let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint} 179 | for constraint in constraints { 180 | constraint.installOnView(updateExisting: true) 181 | } 182 | } 183 | 184 | internal class func removeConstraints(view: View) { 185 | for existingLayoutConstraint in view.snp_installedLayoutConstraints { 186 | existingLayoutConstraint.snp_constraint?.uninstall() 187 | } 188 | } 189 | } -------------------------------------------------------------------------------- /Pods/SnapKit/README.md: -------------------------------------------------------------------------------- 1 | 2 | SnapKit 3 | 4 | ==== 5 | 6 | [![Build Status](https://travis-ci.org/SnapKit/SnapKit.svg)](https://travis-ci.org/SnapKit/SnapKit) 7 | 8 | SnapKit is a light-weight layout framework which wraps AutoLayout with a nicer syntax. SnapKit has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable. SnapKit supports both iOS and OS X. 9 | 10 | > SnapKit uses some Swift-only features like function overloading, so it cannot be used from Objective-C. Because of this we’ve chosen to swap prefixes from Masonry’s `mas_` to `snp_` so you can use both Masonry and SnapKit in the same project. 11 | 12 | ## Requirements 13 | 14 | * iOS 7.0+ / Mac OS X 10.9+ 15 | * Xcode 6.1 16 | 17 | ## Installation 18 | 19 | > **Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks.** 20 | 21 | ### CocoaPods 22 | 23 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. 24 | 25 | CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command: 26 | 27 | ```bash 28 | $ gem install cocoapods 29 | ``` 30 | 31 | To integrate SnapKit into your Xcode project using CocoaPods, specify it in your `Podfile`: 32 | 33 | ```ruby 34 | source 'https://github.com/CocoaPods/Specs.git' 35 | platform :ios, '8.0' 36 | use_frameworks! 37 | 38 | pod 'SnapKit', '~> 0.10.0' 39 | ``` 40 | 41 | Then, run the following command: 42 | 43 | ```bash 44 | $ pod install 45 | ``` 46 | 47 | ### Carthage 48 | 49 | Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application. 50 | 51 | You can install Carthage with [Homebrew](http://brew.sh/) using the following command: 52 | 53 | ```bash 54 | $ brew update 55 | $ brew install carthage 56 | ``` 57 | 58 | To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`: 59 | 60 | ``` 61 | github "SnapKit/SnapKit" >= 0.10.0 62 | ``` 63 | 64 | ### Manually 65 | 66 | If you prefer not to use either of the aforementioned dependency managers, you can integrate SnapKit into your project manually. 67 | 68 | ### Embedded Framework 69 | 70 | - Add SnapKit as a [submodule](http://git-scm.com/docs/git-submodule) by opening the Terminal, `cd`-ing into your top-level project directory, and entering the following command: 71 | 72 | ```bash 73 | $ git submodule add https://github.com/SnapKit/SnapKit.git 74 | ``` 75 | 76 | - Open the `SnapKit` folder, and drag `SnapKit.xcodeproj` into the file navigator of your app project. 77 | - In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar. 78 | - Ensure that the deployment target of SnapKit.framework matches that of the application target. 79 | - In the tab bar at the top of that window, open the "Build Phases" panel. 80 | - Expand the "Target Dependencies" group, and add `SnapKit.framework`. 81 | - Click on the `+` button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add `SnapKit.framework`. 82 | 83 | ## What's wrong with NSLayoutConstraints? 84 | 85 | Under the hood Auto Layout is a powerful and flexible way of organising and laying out your views. However creating constraints from code is verbose and not very descriptive. 86 | Imagine a simple example in which you want to have a view fill its superview but inset by 10 pixels on every side 87 | ```swift 88 | let superview = self; 89 | 90 | let view1 = UIView() 91 | view1.setTranslatesAutoresizingMaskIntoConstraints(false) 92 | view1.backgroundColor = UIColor.greenColor() 93 | superview.addSubview(view1) 94 | 95 | let padding = UIEdgeInsetsMake(10, 10, 10, 10) 96 | 97 | superview.addConstraints([ 98 | NSLayoutConstraint( 99 | item: view1, 100 | attribute: NSLayoutAttribute.Top, 101 | relatedBy: NSLayoutRelation.Equal, 102 | toItem: superview, 103 | attribute: NSLayoutAttribute.Top, 104 | multiplier: 1.0, 105 | constant: padding.top 106 | ), 107 | NSLayoutConstraint( 108 | item: view1, 109 | attribute: NSLayoutAttribute.Left, 110 | relatedBy: NSLayoutRelation.Equal, 111 | toItem: superview, 112 | attribute: NSLayoutAttribute.Left, 113 | multiplier: 1.0, 114 | constant: padding.left 115 | ), 116 | NSLayoutConstraint( 117 | item: view1, 118 | attribute: NSLayoutAttribute.Bottom, 119 | relatedBy: NSLayoutRelation.Equal, 120 | toItem: superview, 121 | attribute: NSLayoutAttribute.Bottom, 122 | multiplier: 1.0, 123 | constant: -padding.bottom 124 | ), 125 | NSLayoutConstraint( 126 | item: view1, 127 | attribute: NSLayoutAttribute.Right, 128 | relatedBy: NSLayoutRelation.Equal, 129 | toItem: superview, 130 | attribute: NSLayoutAttribute.Right, 131 | multiplier: 1.0, 132 | constant: -padding.right 133 | ) 134 | ]) 135 | ``` 136 | Even with such a simple example the code needed is quite verbose and quickly becomes unreadable when you have more than 2 or 3 views. 137 | Another option is to use Visual Format Language (VFL), which is a bit less long winded. 138 | However the ASCII type syntax has its own pitfalls and its also a bit harder to animate as `NSLayoutConstraint.constraintsWithVisualFormat` returns an array. 139 | 140 | ## Prepare to meet your Maker! 141 | 142 | Heres the same constraints created using ConstraintMaker 143 | 144 | ```swift 145 | let padding = UIEdgeInsetsMake(10, 10, 10, 10) 146 | 147 | view1.snp_makeConstraints { (make) -> Void in 148 | make.top.equalTo(superview.snp_top).offset(padding.top) 149 | make.left.equalTo(superview.snp_left).offset(padding.left) 150 | make.bottom.equalTo(superview.snp_bottom).offset(-padding.bottom) 151 | make.right.equalTo(superview.snp_right).offset(-padding.right) 152 | } 153 | ``` 154 | Or even shorter 155 | 156 | ```swift 157 | view1.snp_makeConstraints { (make) -> Void in 158 | make.edges.equalTo(superview).insets(padding) 159 | } 160 | ``` 161 | 162 | Also note in the first example we had to add the constraints to the superview `superview.addConstraints`. 163 | SnapKit however will automagically add constraints to the appropriate view. 164 | 165 | SnapKit will also call `view1.setTranslatesAutoresizingMaskIntoConstraints(false)` for you. 166 | 167 | ## Not all things are created equal 168 | 169 | > `.equalTo` equivalent to **NSLayoutRelation.Equal** 170 | 171 | > `.lessThanOrEqualTo` equivalent to **NSLayoutRelation.LessThanOrEqual** 172 | 173 | > `.greaterThanOrEqualTo` equivalent to **NSLayoutRelation.GreaterThanOrEqual** 174 | 175 | These three equality constraints accept one argument which can be any of the following: 176 | 177 | #### 1. ViewAttribute 178 | 179 | ```swift 180 | make.centerX.lessThanOrEqualTo(view2.snp_left) 181 | ``` 182 | 183 | ViewAttribute | NSLayoutAttribute 184 | ------------------------- | -------------------------- 185 | view.snp_left | NSLayoutAttribute.Left 186 | view.snp_right | NSLayoutAttribute.Right 187 | view.snp_top | NSLayoutAttribute.Top 188 | view.snp_bottom | NSLayoutAttribute.Bottom 189 | view.snp_leading | NSLayoutAttribute.Leading 190 | view.snp_trailing | NSLayoutAttribute.Trailing 191 | view.snp_width | NSLayoutAttribute.Width 192 | view.snp_height | NSLayoutAttribute.Height 193 | view.snp_centerX | NSLayoutAttribute.CenterX 194 | view.snp_centerY | NSLayoutAttribute.CenterY 195 | view.snp_baseline | NSLayoutAttribute.Baseline 196 | 197 | #### 2. UIView/NSView 198 | 199 | if you want view.left to be greater than or equal to label.left : 200 | ```swift 201 | // these two constraints are exactly the same 202 | make.left.greaterThanOrEqualTo(label) 203 | make.left.greaterThanOrEqualTo(label.snp_left) 204 | ``` 205 | 206 | #### 3. Strict Checks 207 | 208 | Auto Layout allows width and height to be set to constant values. 209 | if you want to set view to have a minimum and maximum width you could pass a primitive to the equality blocks: 210 | ```swift 211 | // width >= 200 && width <= 400 212 | make.width.greaterThanOrEqualTo(200) 213 | make.width.lessThanOrEqualTo(400) 214 | ``` 215 | 216 | However Auto Layout does not allow alignment attributes such as left, right, centerY etc to be set to constant values. 217 | So if you pass a primitive for these attributes SnapKit will turn these into constraints relative to the view’s superview ie: 218 | ```swift 219 | // creates view.left <= view.superview.left + 10 220 | make.left.lessThanOrEqualTo(10) 221 | ``` 222 | 223 | You can also use other primitives and structs to build your constraints, like so: 224 | ```swift 225 | make.top.equalTo(42) 226 | make.height.equalTo(20) 227 | make.size.equalTo(CGSizeMake(50, 100)) 228 | make.edges.equalTo(UIEdgeInsetsMake(10, 0, 10, 0)) 229 | make.left.equalTo(view).offset(UIEdgeInsetsMake(10, 0, 10, 0)) 230 | ``` 231 | 232 | ## Learn to prioritize 233 | 234 | > `.prority` allows you to specify an exact priority 235 | 236 | > `.priorityHigh` equivalent to **UILayoutPriority.DefaultHigh** 237 | 238 | > `.priorityMedium` is half way between high and low 239 | 240 | > `.priorityLow` equivalent to **UILayoutPriority.DefaultLow** 241 | 242 | Priorities are can be tacked on to the end of a constraint chain like so: 243 | ```swift 244 | make.left.greaterThanOrEqualTo(label.snp_left).priorityLow(); 245 | 246 | make.top.equalTo(label.snp_top).priority(600); 247 | ``` 248 | 249 | ## Composition, composition, composition 250 | 251 | SnapKit also gives you a few convenience methods which create multiple constraints at the same time. 252 | 253 | #### edges 254 | 255 | ```swift 256 | // make top, left, bottom, right equal view2 257 | make.edges.equalTo(view2); 258 | 259 | // make top = superview.top + 5, left = superview.left + 10, 260 | // bottom = superview.bottom - 15, right = superview.right - 20 261 | make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20)) 262 | ``` 263 | 264 | #### size 265 | 266 | ```swift 267 | // make width and height greater than or equal to titleLabel 268 | make.size.greaterThanOrEqualTo(titleLabel) 269 | 270 | // make width = superview.width + 100, height = superview.height - 50 271 | make.size.equalTo(superview).offset(CGSizeMake(100, -50)) 272 | ``` 273 | 274 | #### center 275 | 276 | ```swift 277 | // make centerX and centerY = button1 278 | make.center.equalTo(button1) 279 | 280 | // make centerX = superview.centerX - 5, centerY = superview.centerY + 10 281 | make.center.equalTo(superview).offset(CGPointMake(-5, 10)) 282 | ``` 283 | 284 | You can chain view attributes for increased readability: 285 | 286 | ```swift 287 | // All edges but the top should equal those of the superview 288 | make.left.right.bottom.equalTo(superview) 289 | make.top.equalTo(otherView) 290 | ``` 291 | 292 | ## Hold on for dear life 293 | 294 | Sometimes you need modify existing constraints in order to animate or remove/replace constraints. 295 | In SnapKit there are a few different approaches to updating constraints. 296 | 297 | #### 1. References 298 | You can hold on to a reference of a particular constraint by assigning the result of a constraint make expression to a local variable or a class property. 299 | You could also reference multiple constraints by storing them away in an array. 300 | 301 | ```swift 302 | 303 | var topConstraint: Constraint? = nil 304 | 305 | ... 306 | 307 | // when making constraints 308 | view1.snp_makeConstraints { make in 309 | self.topConstraint = make.top.equalTo(superview).offset(padding.top).constraint 310 | make.left.equalTo(superview).offset(padding.left) 311 | } 312 | 313 | ... 314 | // then later you can call 315 | self.topConstraint.uninstall() 316 | ``` 317 | 318 | ### 2. snp_remakeConstraints 319 | 320 | `snp_remakeConstraints` is similar to `snp_makeConstraints`, but will first remove all existing constraints installed by SnapKit. 321 | 322 | ```swift 323 | func changeButtonPosition() { 324 | self.button.snp_remakeConstraints { make in 325 | make.size.equalTo(self.buttonSize) 326 | 327 | if topLeft { 328 | make.top.left.equalTo(10) 329 | } else { 330 | make.bottom.equalTo(self.view).offset(-10) 331 | make.right.equalTo(self.view).offset(-10) 332 | } 333 | } 334 | } 335 | ``` 336 | 337 | ## Code Snippets 338 | 339 | Copy the included code snippets to ``~/Library/Developer/Xcode/UserData/CodeSnippets`` to write your snap closures at lightning speed! 340 | 341 | `snp_make` -> `.snp_makeConstraints { make in }` 342 | 343 | `snp_remake` -> `.snp_remakeConstraints { make in }` 344 | 345 | ## TODO 346 | 347 | * Eye candy 348 | * Example projects 349 | * Tests 350 | -------------------------------------------------------------------------------- /QRCodeByAVFoundation/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 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 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 121 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/Constraint.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to expose API's for a Constraint 32 | */ 33 | public class Constraint { 34 | 35 | public func install() -> [LayoutConstraint] { fatalError("Must be implemented by Concrete subclass.") } 36 | public func uninstall() -> Void { fatalError("Must be implemented by Concrete subclass.") } 37 | public func activate() -> Void { fatalError("Must be implemented by Concrete subclass.") } 38 | public func deactivate() -> Void { fatalError("Must be implemented by Concrete subclass.") } 39 | 40 | public func updateOffset(amount: Float) -> Void { fatalError("Must be implemented by Concrete subclass.") } 41 | public func updateOffset(amount: Double) -> Void { fatalError("Must be implemented by Concrete subclass.") } 42 | public func updateOffset(amount: CGFloat) -> Void { fatalError("Must be implemented by Concrete subclass.") } 43 | public func updateOffset(amount: Int) -> Void { fatalError("Must be implemented by Concrete subclass.") } 44 | public func updateOffset(amount: UInt) -> Void { fatalError("Must be implemented by Concrete subclass.") } 45 | public func updateOffset(amount: CGPoint) -> Void { fatalError("Must be implemented by Concrete subclass.") } 46 | public func updateOffset(amount: CGSize) -> Void { fatalError("Must be implemented by Concrete subclass.") } 47 | public func updateOffset(amount: EdgeInsets) -> Void { fatalError("Must be implemented by Concrete subclass.") } 48 | 49 | public func updateInsets(amount: EdgeInsets) -> Void { fatalError("Must be implemented by Concrete subclass.") } 50 | 51 | public func updatePriority(priority: Float) -> Void { fatalError("Must be implemented by Concrete subclass.") } 52 | public func updatePriority(priority: Double) -> Void { fatalError("Must be implemented by Concrete subclass.") } 53 | public func updatePriority(priority: CGFloat) -> Void { fatalError("Must be implemented by Concrete subclass.") } 54 | public func updatePriority(priority: UInt) -> Void { fatalError("Must be implemented by Concrete subclass.") } 55 | public func updatePriority(priority: Int) -> Void { fatalError("Must be implemented by Concrete subclass.") } 56 | public func updatePriorityRequired() -> Void { fatalError("Must be implemented by Concrete subclass.") } 57 | public func updatePriorityHigh() -> Void { fatalError("Must be implemented by Concrete subclass.") } 58 | public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") } 59 | public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") } 60 | 61 | } 62 | 63 | /** 64 | Used internally to implement a ConcreteConstraint 65 | */ 66 | final internal class ConcreteConstraint: Constraint { 67 | 68 | internal override func updateOffset(amount: Float) -> Void { 69 | self.constant = amount 70 | } 71 | internal override func updateOffset(amount: Double) -> Void { 72 | self.updateOffset(Float(amount)) 73 | } 74 | internal override func updateOffset(amount: CGFloat) -> Void { 75 | self.updateOffset(Float(amount)) 76 | } 77 | internal override func updateOffset(amount: Int) -> Void { 78 | self.updateOffset(Float(amount)) 79 | } 80 | internal override func updateOffset(amount: UInt) -> Void { 81 | self.updateOffset(Float(amount)) 82 | } 83 | internal override func updateOffset(amount: CGPoint) -> Void { 84 | self.constant = amount 85 | } 86 | internal override func updateOffset(amount: CGSize) -> Void { 87 | self.constant = amount 88 | } 89 | internal override func updateOffset(amount: EdgeInsets) -> Void { 90 | self.constant = amount 91 | } 92 | 93 | internal override func updateInsets(amount: EdgeInsets) -> Void { 94 | self.constant = EdgeInsets(top: amount.top, left: amount.left, bottom: -amount.bottom, right: -amount.right) 95 | } 96 | 97 | internal override func updatePriority(priority: Float) -> Void { 98 | self.priority = priority 99 | } 100 | internal override func updatePriority(priority: Double) -> Void { 101 | self.updatePriority(Float(priority)) 102 | } 103 | internal override func updatePriority(priority: CGFloat) -> Void { 104 | self.updatePriority(Float(priority)) 105 | } 106 | internal override func updatePriority(priority: UInt) -> Void { 107 | self.updatePriority(Float(priority)) 108 | } 109 | internal override func updatePriority(priority: Int) -> Void { 110 | self.updatePriority(Float(priority)) 111 | } 112 | internal override func updatePriorityRequired() -> Void { 113 | self.updatePriority(Float(1000.0)) 114 | } 115 | internal override func updatePriorityHigh() -> Void { 116 | self.updatePriority(Float(750.0)) 117 | } 118 | internal override func updatePriorityMedium() -> Void { 119 | #if os(iOS) 120 | self.updatePriority(Float(500.0)) 121 | #else 122 | self.updatePriority(Float(501.0)) 123 | #endif 124 | } 125 | internal override func updatePriorityLow() -> Void { 126 | self.updatePriority(Float(250.0)) 127 | } 128 | 129 | internal override func install() -> [LayoutConstraint] { 130 | return self.installOnView(updateExisting: false) 131 | } 132 | 133 | internal override func uninstall() -> Void { 134 | self.uninstallFromView() 135 | } 136 | 137 | internal override func activate() -> Void { 138 | if NSLayoutConstraint.respondsToSelector("activateConstraints:") && self.installInfo != nil { 139 | let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint] 140 | if layoutConstraints.count > 0 { 141 | NSLayoutConstraint.activateConstraints(layoutConstraints) 142 | } 143 | } else { 144 | self.install() 145 | } 146 | } 147 | 148 | internal override func deactivate() -> Void { 149 | if NSLayoutConstraint.respondsToSelector("deactivateConstraints:") && self.installInfo != nil { 150 | let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint] 151 | if layoutConstraints.count > 0 { 152 | NSLayoutConstraint.deactivateConstraints(layoutConstraints) 153 | } 154 | } else { 155 | self.uninstall() 156 | } 157 | } 158 | 159 | private let fromItem: ConstraintItem 160 | private let toItem: ConstraintItem 161 | private let relation: ConstraintRelation 162 | private let multiplier: Float 163 | private var constant: Any { 164 | didSet { 165 | if let installInfo = self.installInfo { 166 | for layoutConstraint in installInfo.layoutConstraints.allObjects as! [LayoutConstraint] { 167 | let attribute = (layoutConstraint.secondAttribute == .NotAnAttribute) ? layoutConstraint.firstAttribute : layoutConstraint.secondAttribute 168 | layoutConstraint.constant = attribute.snp_constantForValue(self.constant) 169 | } 170 | } 171 | } 172 | } 173 | private var priority: Float { 174 | didSet { 175 | if let installInfo = self.installInfo { 176 | for layoutConstraint in installInfo.layoutConstraints.allObjects as! [LayoutConstraint] { 177 | layoutConstraint.priority = self.priority 178 | } 179 | } 180 | } 181 | } 182 | 183 | private var installInfo: ConcreteConstraintInstallInfo? = nil 184 | 185 | internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float) { 186 | self.fromItem = fromItem 187 | self.toItem = toItem 188 | self.relation = relation 189 | self.constant = constant 190 | self.multiplier = multiplier 191 | self.priority = priority 192 | } 193 | 194 | internal func installOnView(updateExisting: Bool = false) -> [LayoutConstraint] { 195 | var installOnView: View? = nil 196 | if self.toItem.view != nil { 197 | installOnView = closestCommonSuperviewBetween(self.fromItem.view, self.toItem.view) 198 | if installOnView == nil { 199 | NSException(name: "Cannot Install Constraint", reason: "No common superview between views", userInfo: nil).raise() 200 | return [] 201 | } 202 | } else { 203 | installOnView = self.fromItem.view?.superview 204 | if installOnView == nil { 205 | if self.fromItem.attributes == ConstraintAttributes.Width || self.fromItem.attributes == ConstraintAttributes.Height { 206 | installOnView = self.fromItem.view 207 | } 208 | 209 | if installOnView == nil { 210 | NSException(name: "Cannot Install Constraint", reason: "Missing superview", userInfo: nil).raise() 211 | return [] 212 | } 213 | } 214 | } 215 | 216 | if let installedOnView = self.installInfo?.view { 217 | if installedOnView != installOnView { 218 | NSException(name: "Cannot Install Constraint", reason: "Already installed on different view.", userInfo: nil).raise() 219 | return [] 220 | } 221 | return self.installInfo?.layoutConstraints.allObjects as? [LayoutConstraint] ?? [] 222 | } 223 | 224 | var newLayoutConstraints = [LayoutConstraint]() 225 | let layoutFromAttributes = self.fromItem.attributes.layoutAttributes 226 | let layoutToAttributes = self.toItem.attributes.layoutAttributes 227 | 228 | // get layout from 229 | let layoutFrom: View? = self.fromItem.view 230 | 231 | // get layout relation 232 | let layoutRelation: NSLayoutRelation = self.relation.layoutRelation 233 | 234 | for layoutFromAttribute in layoutFromAttributes { 235 | // get layout to attribute 236 | let layoutToAttribute = (layoutToAttributes.count > 0) ? layoutToAttributes[0] : layoutFromAttribute 237 | 238 | // get layout constant 239 | var layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant) 240 | 241 | // get layout to 242 | var layoutTo: View? = self.toItem.view 243 | if layoutTo == nil && layoutToAttribute != .Width && layoutToAttribute != .Height { 244 | layoutTo = installOnView 245 | } 246 | 247 | // create layout constraint 248 | let layoutConstraint = LayoutConstraint( 249 | item: layoutFrom!, 250 | attribute: layoutFromAttribute, 251 | relatedBy: layoutRelation, 252 | toItem: layoutTo, 253 | attribute: layoutToAttribute, 254 | multiplier: CGFloat(self.multiplier), 255 | constant: layoutConstant) 256 | 257 | // set priority 258 | layoutConstraint.priority = self.priority 259 | 260 | // set constraint 261 | layoutConstraint.snp_constraint = self 262 | 263 | newLayoutConstraints.append(layoutConstraint) 264 | } 265 | 266 | // special logic for updating 267 | if updateExisting { 268 | // get existing constraints for this view 269 | let existingLayoutConstraints = reverse(layoutFrom!.snp_installedLayoutConstraints) 270 | 271 | // array that will contain only new layout constraints to keep 272 | var newLayoutConstraintsToKeep = [LayoutConstraint]() 273 | 274 | // begin looping 275 | for layoutConstraint in newLayoutConstraints { 276 | // layout constraint that should be updated 277 | var updateLayoutConstraint: LayoutConstraint? = nil 278 | 279 | // loop through existing and check for match 280 | for existingLayoutConstraint in existingLayoutConstraints { 281 | if existingLayoutConstraint == layoutConstraint { 282 | updateLayoutConstraint = existingLayoutConstraint 283 | break 284 | } 285 | } 286 | 287 | // if we have existing one lets just update the constant 288 | if updateLayoutConstraint != nil { 289 | updateLayoutConstraint!.constant = layoutConstraint.constant 290 | } 291 | // otherwise add this layout constraint to new keep list 292 | else { 293 | newLayoutConstraintsToKeep.append(layoutConstraint) 294 | } 295 | } 296 | 297 | // set constraints to only new ones 298 | newLayoutConstraints = newLayoutConstraintsToKeep 299 | } 300 | 301 | // add constraints 302 | installOnView!.addConstraints(newLayoutConstraints) 303 | 304 | // set install info 305 | self.installInfo = ConcreteConstraintInstallInfo(view: installOnView, layoutConstraints: NSHashTable.weakObjectsHashTable()) 306 | 307 | // store which layout constraints are installed for this constraint 308 | for layoutConstraint in newLayoutConstraints { 309 | self.installInfo!.layoutConstraints.addObject(layoutConstraint) 310 | } 311 | 312 | // store the layout constraints against the layout from view 313 | layoutFrom!.snp_installedLayoutConstraints += newLayoutConstraints 314 | 315 | // return the new constraints 316 | return newLayoutConstraints 317 | } 318 | 319 | internal func uninstallFromView() { 320 | if let installInfo = self.installInfo, 321 | let installedLayoutConstraints = installInfo.layoutConstraints.allObjects as? [LayoutConstraint] { 322 | 323 | if installedLayoutConstraints.count > 0 { 324 | 325 | if let installedOnView = installInfo.view { 326 | // remove the constraints from the UIView's storage 327 | installedOnView.removeConstraints(installedLayoutConstraints) 328 | } 329 | 330 | // remove the constraints from the from item view 331 | if let fromView = self.fromItem.view { 332 | fromView.snp_installedLayoutConstraints = fromView.snp_installedLayoutConstraints.filter { 333 | return !contains(installedLayoutConstraints, $0) 334 | } 335 | } 336 | } 337 | 338 | } 339 | self.installInfo = nil 340 | } 341 | 342 | } 343 | 344 | private struct ConcreteConstraintInstallInfo { 345 | 346 | weak var view: View? = nil 347 | let layoutConstraints: NSHashTable 348 | 349 | } 350 | 351 | private extension NSLayoutAttribute { 352 | 353 | private func snp_constantForValue(value: Any?) -> CGFloat { 354 | // Float 355 | if let float = value as? Float { 356 | return CGFloat(float) 357 | } 358 | // Double 359 | else if let double = value as? Double { 360 | return CGFloat(double) 361 | } 362 | // UInt 363 | else if let int = value as? Int { 364 | return CGFloat(int) 365 | } 366 | // Int 367 | else if let uint = value as? UInt { 368 | return CGFloat(uint) 369 | } 370 | // CGFloat 371 | else if let float = value as? CGFloat { 372 | return float 373 | } 374 | // CGSize 375 | else if let size = value as? CGSize { 376 | if self == .Width { 377 | return size.width 378 | } else if self == .Height { 379 | return size.height 380 | } 381 | } 382 | // CGPoint 383 | else if let point = value as? CGPoint { 384 | #if os(iOS) 385 | switch self { 386 | case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return point.x 387 | case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return point.y 388 | case .Right, .RightMargin: return point.x 389 | case .Bottom, .BottomMargin: return point.y 390 | case .Leading, .LeadingMargin: return point.x 391 | case .Trailing, .TrailingMargin: return point.x 392 | case .Width, .Height, .NotAnAttribute: return CGFloat(0) 393 | } 394 | #else 395 | switch self { 396 | case .Left, .CenterX: return point.x 397 | case .Top, .CenterY, .Baseline: return point.y 398 | case .Right: return point.x 399 | case .Bottom: return point.y 400 | case .Leading: return point.x 401 | case .Trailing: return point.x 402 | case .Width, .Height, .NotAnAttribute: return CGFloat(0) 403 | } 404 | #endif 405 | } 406 | // EdgeInsets 407 | else if let insets = value as? EdgeInsets { 408 | #if os(iOS) 409 | switch self { 410 | case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return insets.left 411 | case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return insets.top 412 | case .Right, .RightMargin: return insets.right 413 | case .Bottom, .BottomMargin: return insets.bottom 414 | case .Leading, .LeadingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right 415 | case .Trailing, .TrailingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left 416 | case .Width, .Height, .NotAnAttribute: return CGFloat(0) 417 | } 418 | #else 419 | switch self { 420 | case .Left, .CenterX: return insets.left 421 | case .Top, .CenterY, .Baseline: return insets.top 422 | case .Right: return insets.right 423 | case .Bottom: return insets.bottom 424 | case .Leading: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right 425 | case .Trailing: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left 426 | case .Width, .Height, .NotAnAttribute: return CGFloat(0) 427 | } 428 | #endif 429 | } 430 | 431 | return CGFloat(0); 432 | } 433 | } 434 | 435 | private func closestCommonSuperviewBetween(fromView: View?, toView: View?) -> View? { 436 | var views = Set() 437 | var fromView = fromView 438 | var toView = toView 439 | do { 440 | if let view = toView { 441 | if views.contains(view) { 442 | return view 443 | } 444 | views.insert(view) 445 | toView = view.superview 446 | } 447 | if let view = fromView { 448 | if views.contains(view) { 449 | return view 450 | } 451 | views.insert(view) 452 | fromView = view.superview 453 | } 454 | } while (fromView != nil || toView != nil) 455 | 456 | return nil 457 | } 458 | 459 | private func ==(left: ConcreteConstraint, right: ConcreteConstraint) -> Bool { 460 | return (left.fromItem == right.fromItem && 461 | left.toItem == right.toItem && 462 | left.relation == right.relation && 463 | left.multiplier == right.multiplier && 464 | left.priority == right.priority) 465 | } -------------------------------------------------------------------------------- /QRCodeByAVFoundation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 17A3CEC6318CD8C810D0EF8B /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32AF838E76F4964C75DBE525 /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 11 | A78B45A51B0C2DB60090941F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78B45A41B0C2DB60090941F /* AppDelegate.swift */; }; 12 | A78B45A71B0C2DB60090941F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78B45A61B0C2DB60090941F /* ViewController.swift */; }; 13 | A78B45AA1B0C2DB60090941F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A78B45A81B0C2DB60090941F /* Main.storyboard */; }; 14 | A78B45AC1B0C2DB60090941F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A78B45AB1B0C2DB60090941F /* Images.xcassets */; }; 15 | A78B45AF1B0C2DB60090941F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = A78B45AD1B0C2DB60090941F /* LaunchScreen.xib */; }; 16 | A78B45BB1B0C2DB60090941F /* QRCodeByAVFoundationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78B45BA1B0C2DB60090941F /* QRCodeByAVFoundationTests.swift */; }; 17 | A78B45DF1B0D60640090941F /* QRCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78B45DE1B0D60640090941F /* QRCodeViewController.swift */; }; 18 | A78B45E71B0DADD30090941F /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A78B45E61B0DADD30090941F /* OverlayView.swift */; }; 19 | A79089DC1B1BE6E80000F9ED /* MyCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A79089DB1B1BE6E80000F9ED /* MyCodeViewController.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | A78B45B51B0C2DB60090941F /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = A78B45971B0C2DB60090941F /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = A78B459E1B0C2DB60090941F; 28 | remoteInfo = QRCodeByAVFoundation; 29 | }; 30 | /* End PBXContainerItemProxy section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 28C5446E3D304E183B8E9B04 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 34 | 32AF838E76F4964C75DBE525 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | A32ED19F254E867240DABC7C /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 36 | A78B459F1B0C2DB60090941F /* QRCodeByAVFoundation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QRCodeByAVFoundation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | A78B45A31B0C2DB60090941F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | A78B45A41B0C2DB60090941F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | A78B45A61B0C2DB60090941F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | A78B45A91B0C2DB60090941F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | A78B45AB1B0C2DB60090941F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 42 | A78B45AE1B0C2DB60090941F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 43 | A78B45B41B0C2DB60090941F /* QRCodeByAVFoundationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QRCodeByAVFoundationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | A78B45B91B0C2DB60090941F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | A78B45BA1B0C2DB60090941F /* QRCodeByAVFoundationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeByAVFoundationTests.swift; sourceTree = ""; }; 46 | A78B45DE1B0D60640090941F /* QRCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QRCodeViewController.swift; sourceTree = ""; }; 47 | A78B45E61B0DADD30090941F /* OverlayView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverlayView.swift; sourceTree = ""; }; 48 | A79089DB1B1BE6E80000F9ED /* MyCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyCodeViewController.swift; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | A78B459C1B0C2DB60090941F /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | 17A3CEC6318CD8C810D0EF8B /* Pods.framework in Frameworks */, 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | A78B45B11B0C2DB60090941F /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | 3751830D5B53CCC88E0C665A /* Pods */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | A32ED19F254E867240DABC7C /* Pods.debug.xcconfig */, 74 | 28C5446E3D304E183B8E9B04 /* Pods.release.xcconfig */, 75 | ); 76 | name = Pods; 77 | sourceTree = ""; 78 | }; 79 | 7328CF36A3B2B3C5163A1682 /* Frameworks */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 32AF838E76F4964C75DBE525 /* Pods.framework */, 83 | ); 84 | name = Frameworks; 85 | sourceTree = ""; 86 | }; 87 | A78B45961B0C2DB60090941F = { 88 | isa = PBXGroup; 89 | children = ( 90 | A78B45A11B0C2DB60090941F /* QRCodeByAVFoundation */, 91 | A78B45B71B0C2DB60090941F /* QRCodeByAVFoundationTests */, 92 | A78B45A01B0C2DB60090941F /* Products */, 93 | 3751830D5B53CCC88E0C665A /* Pods */, 94 | 7328CF36A3B2B3C5163A1682 /* Frameworks */, 95 | ); 96 | sourceTree = ""; 97 | }; 98 | A78B45A01B0C2DB60090941F /* Products */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | A78B459F1B0C2DB60090941F /* QRCodeByAVFoundation.app */, 102 | A78B45B41B0C2DB60090941F /* QRCodeByAVFoundationTests.xctest */, 103 | ); 104 | name = Products; 105 | sourceTree = ""; 106 | }; 107 | A78B45A11B0C2DB60090941F /* QRCodeByAVFoundation */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | A78B45A41B0C2DB60090941F /* AppDelegate.swift */, 111 | A78B45A61B0C2DB60090941F /* ViewController.swift */, 112 | A78B45DE1B0D60640090941F /* QRCodeViewController.swift */, 113 | A79089DB1B1BE6E80000F9ED /* MyCodeViewController.swift */, 114 | A78B45E61B0DADD30090941F /* OverlayView.swift */, 115 | A78B45A81B0C2DB60090941F /* Main.storyboard */, 116 | A78B45AB1B0C2DB60090941F /* Images.xcassets */, 117 | A78B45AD1B0C2DB60090941F /* LaunchScreen.xib */, 118 | A78B45A21B0C2DB60090941F /* Supporting Files */, 119 | ); 120 | path = QRCodeByAVFoundation; 121 | sourceTree = ""; 122 | }; 123 | A78B45A21B0C2DB60090941F /* Supporting Files */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | A78B45A31B0C2DB60090941F /* Info.plist */, 127 | ); 128 | name = "Supporting Files"; 129 | sourceTree = ""; 130 | }; 131 | A78B45B71B0C2DB60090941F /* QRCodeByAVFoundationTests */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | A78B45BA1B0C2DB60090941F /* QRCodeByAVFoundationTests.swift */, 135 | A78B45B81B0C2DB60090941F /* Supporting Files */, 136 | ); 137 | path = QRCodeByAVFoundationTests; 138 | sourceTree = ""; 139 | }; 140 | A78B45B81B0C2DB60090941F /* Supporting Files */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | A78B45B91B0C2DB60090941F /* Info.plist */, 144 | ); 145 | name = "Supporting Files"; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXNativeTarget section */ 151 | A78B459E1B0C2DB60090941F /* QRCodeByAVFoundation */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = A78B45BE1B0C2DB60090941F /* Build configuration list for PBXNativeTarget "QRCodeByAVFoundation" */; 154 | buildPhases = ( 155 | FF245FA6733B2814A08FC0F2 /* Check Pods Manifest.lock */, 156 | A78B459B1B0C2DB60090941F /* Sources */, 157 | A78B459C1B0C2DB60090941F /* Frameworks */, 158 | A78B459D1B0C2DB60090941F /* Resources */, 159 | 2B20F026AFF57B3AE60AB782 /* Embed Pods Frameworks */, 160 | 68C8281E82BE4496C2B37BFD /* Copy Pods Resources */, 161 | ); 162 | buildRules = ( 163 | ); 164 | dependencies = ( 165 | ); 166 | name = QRCodeByAVFoundation; 167 | productName = QRCodeByAVFoundation; 168 | productReference = A78B459F1B0C2DB60090941F /* QRCodeByAVFoundation.app */; 169 | productType = "com.apple.product-type.application"; 170 | }; 171 | A78B45B31B0C2DB60090941F /* QRCodeByAVFoundationTests */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = A78B45C11B0C2DB60090941F /* Build configuration list for PBXNativeTarget "QRCodeByAVFoundationTests" */; 174 | buildPhases = ( 175 | A78B45B01B0C2DB60090941F /* Sources */, 176 | A78B45B11B0C2DB60090941F /* Frameworks */, 177 | A78B45B21B0C2DB60090941F /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | A78B45B61B0C2DB60090941F /* PBXTargetDependency */, 183 | ); 184 | name = QRCodeByAVFoundationTests; 185 | productName = QRCodeByAVFoundationTests; 186 | productReference = A78B45B41B0C2DB60090941F /* QRCodeByAVFoundationTests.xctest */; 187 | productType = "com.apple.product-type.bundle.unit-test"; 188 | }; 189 | /* End PBXNativeTarget section */ 190 | 191 | /* Begin PBXProject section */ 192 | A78B45971B0C2DB60090941F /* Project object */ = { 193 | isa = PBXProject; 194 | attributes = { 195 | LastUpgradeCheck = 0630; 196 | ORGANIZATIONNAME = Tommy; 197 | TargetAttributes = { 198 | A78B459E1B0C2DB60090941F = { 199 | CreatedOnToolsVersion = 6.3.1; 200 | }; 201 | A78B45B31B0C2DB60090941F = { 202 | CreatedOnToolsVersion = 6.3.1; 203 | TestTargetID = A78B459E1B0C2DB60090941F; 204 | }; 205 | }; 206 | }; 207 | buildConfigurationList = A78B459A1B0C2DB60090941F /* Build configuration list for PBXProject "QRCodeByAVFoundation" */; 208 | compatibilityVersion = "Xcode 3.2"; 209 | developmentRegion = English; 210 | hasScannedForEncodings = 0; 211 | knownRegions = ( 212 | en, 213 | Base, 214 | ); 215 | mainGroup = A78B45961B0C2DB60090941F; 216 | productRefGroup = A78B45A01B0C2DB60090941F /* Products */; 217 | projectDirPath = ""; 218 | projectRoot = ""; 219 | targets = ( 220 | A78B459E1B0C2DB60090941F /* QRCodeByAVFoundation */, 221 | A78B45B31B0C2DB60090941F /* QRCodeByAVFoundationTests */, 222 | ); 223 | }; 224 | /* End PBXProject section */ 225 | 226 | /* Begin PBXResourcesBuildPhase section */ 227 | A78B459D1B0C2DB60090941F /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | A78B45AA1B0C2DB60090941F /* Main.storyboard in Resources */, 232 | A78B45AF1B0C2DB60090941F /* LaunchScreen.xib in Resources */, 233 | A78B45AC1B0C2DB60090941F /* Images.xcassets in Resources */, 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | }; 237 | A78B45B21B0C2DB60090941F /* Resources */ = { 238 | isa = PBXResourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | /* End PBXResourcesBuildPhase section */ 245 | 246 | /* Begin PBXShellScriptBuildPhase section */ 247 | 2B20F026AFF57B3AE60AB782 /* Embed Pods Frameworks */ = { 248 | isa = PBXShellScriptBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | ); 252 | inputPaths = ( 253 | ); 254 | name = "Embed Pods Frameworks"; 255 | outputPaths = ( 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | shellPath = /bin/sh; 259 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; 260 | showEnvVarsInLog = 0; 261 | }; 262 | 68C8281E82BE4496C2B37BFD /* Copy Pods Resources */ = { 263 | isa = PBXShellScriptBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | ); 267 | inputPaths = ( 268 | ); 269 | name = "Copy Pods Resources"; 270 | outputPaths = ( 271 | ); 272 | runOnlyForDeploymentPostprocessing = 0; 273 | shellPath = /bin/sh; 274 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; 275 | showEnvVarsInLog = 0; 276 | }; 277 | FF245FA6733B2814A08FC0F2 /* Check Pods Manifest.lock */ = { 278 | isa = PBXShellScriptBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | ); 282 | inputPaths = ( 283 | ); 284 | name = "Check Pods Manifest.lock"; 285 | outputPaths = ( 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | shellPath = /bin/sh; 289 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 290 | showEnvVarsInLog = 0; 291 | }; 292 | /* End PBXShellScriptBuildPhase section */ 293 | 294 | /* Begin PBXSourcesBuildPhase section */ 295 | A78B459B1B0C2DB60090941F /* Sources */ = { 296 | isa = PBXSourcesBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | A78B45A71B0C2DB60090941F /* ViewController.swift in Sources */, 300 | A78B45A51B0C2DB60090941F /* AppDelegate.swift in Sources */, 301 | A78B45DF1B0D60640090941F /* QRCodeViewController.swift in Sources */, 302 | A78B45E71B0DADD30090941F /* OverlayView.swift in Sources */, 303 | A79089DC1B1BE6E80000F9ED /* MyCodeViewController.swift in Sources */, 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | A78B45B01B0C2DB60090941F /* Sources */ = { 308 | isa = PBXSourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | A78B45BB1B0C2DB60090941F /* QRCodeByAVFoundationTests.swift in Sources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | /* End PBXSourcesBuildPhase section */ 316 | 317 | /* Begin PBXTargetDependency section */ 318 | A78B45B61B0C2DB60090941F /* PBXTargetDependency */ = { 319 | isa = PBXTargetDependency; 320 | target = A78B459E1B0C2DB60090941F /* QRCodeByAVFoundation */; 321 | targetProxy = A78B45B51B0C2DB60090941F /* PBXContainerItemProxy */; 322 | }; 323 | /* End PBXTargetDependency section */ 324 | 325 | /* Begin PBXVariantGroup section */ 326 | A78B45A81B0C2DB60090941F /* Main.storyboard */ = { 327 | isa = PBXVariantGroup; 328 | children = ( 329 | A78B45A91B0C2DB60090941F /* Base */, 330 | ); 331 | name = Main.storyboard; 332 | sourceTree = ""; 333 | }; 334 | A78B45AD1B0C2DB60090941F /* LaunchScreen.xib */ = { 335 | isa = PBXVariantGroup; 336 | children = ( 337 | A78B45AE1B0C2DB60090941F /* Base */, 338 | ); 339 | name = LaunchScreen.xib; 340 | sourceTree = ""; 341 | }; 342 | /* End PBXVariantGroup section */ 343 | 344 | /* Begin XCBuildConfiguration section */ 345 | A78B45BC1B0C2DB60090941F /* Debug */ = { 346 | isa = XCBuildConfiguration; 347 | buildSettings = { 348 | ALWAYS_SEARCH_USER_PATHS = NO; 349 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 350 | CLANG_CXX_LIBRARY = "libc++"; 351 | CLANG_ENABLE_MODULES = YES; 352 | CLANG_ENABLE_OBJC_ARC = YES; 353 | CLANG_WARN_BOOL_CONVERSION = YES; 354 | CLANG_WARN_CONSTANT_CONVERSION = YES; 355 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 356 | CLANG_WARN_EMPTY_BODY = YES; 357 | CLANG_WARN_ENUM_CONVERSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_UNREACHABLE_CODE = YES; 361 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 362 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 363 | COPY_PHASE_STRIP = NO; 364 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 365 | ENABLE_STRICT_OBJC_MSGSEND = YES; 366 | GCC_C_LANGUAGE_STANDARD = gnu99; 367 | GCC_DYNAMIC_NO_PIC = NO; 368 | GCC_NO_COMMON_BLOCKS = YES; 369 | GCC_OPTIMIZATION_LEVEL = 0; 370 | GCC_PREPROCESSOR_DEFINITIONS = ( 371 | "DEBUG=1", 372 | "$(inherited)", 373 | ); 374 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 375 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 376 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 377 | GCC_WARN_UNDECLARED_SELECTOR = YES; 378 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 379 | GCC_WARN_UNUSED_FUNCTION = YES; 380 | GCC_WARN_UNUSED_VARIABLE = YES; 381 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 382 | MTL_ENABLE_DEBUG_INFO = YES; 383 | ONLY_ACTIVE_ARCH = YES; 384 | SDKROOT = iphoneos; 385 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 386 | }; 387 | name = Debug; 388 | }; 389 | A78B45BD1B0C2DB60090941F /* Release */ = { 390 | isa = XCBuildConfiguration; 391 | buildSettings = { 392 | ALWAYS_SEARCH_USER_PATHS = NO; 393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 394 | CLANG_CXX_LIBRARY = "libc++"; 395 | CLANG_ENABLE_MODULES = YES; 396 | CLANG_ENABLE_OBJC_ARC = YES; 397 | CLANG_WARN_BOOL_CONVERSION = YES; 398 | CLANG_WARN_CONSTANT_CONVERSION = YES; 399 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 400 | CLANG_WARN_EMPTY_BODY = YES; 401 | CLANG_WARN_ENUM_CONVERSION = YES; 402 | CLANG_WARN_INT_CONVERSION = YES; 403 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 404 | CLANG_WARN_UNREACHABLE_CODE = YES; 405 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 406 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 407 | COPY_PHASE_STRIP = NO; 408 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 409 | ENABLE_NS_ASSERTIONS = NO; 410 | ENABLE_STRICT_OBJC_MSGSEND = YES; 411 | GCC_C_LANGUAGE_STANDARD = gnu99; 412 | GCC_NO_COMMON_BLOCKS = YES; 413 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 414 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 415 | GCC_WARN_UNDECLARED_SELECTOR = YES; 416 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 417 | GCC_WARN_UNUSED_FUNCTION = YES; 418 | GCC_WARN_UNUSED_VARIABLE = YES; 419 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 420 | MTL_ENABLE_DEBUG_INFO = NO; 421 | SDKROOT = iphoneos; 422 | VALIDATE_PRODUCT = YES; 423 | }; 424 | name = Release; 425 | }; 426 | A78B45BF1B0C2DB60090941F /* Debug */ = { 427 | isa = XCBuildConfiguration; 428 | baseConfigurationReference = A32ED19F254E867240DABC7C /* Pods.debug.xcconfig */; 429 | buildSettings = { 430 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 431 | CLANG_ENABLE_MODULES = YES; 432 | CODE_SIGN_IDENTITY = "iPhone Developer: kaihong luo (H536M777VC)"; 433 | INFOPLIST_FILE = QRCodeByAVFoundation/Info.plist; 434 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 435 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 436 | PRODUCT_NAME = "$(TARGET_NAME)"; 437 | PROVISIONING_PROFILE = "b3912e16-814d-42a0-86b7-a7983b159c6a"; 438 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 439 | }; 440 | name = Debug; 441 | }; 442 | A78B45C01B0C2DB60090941F /* Release */ = { 443 | isa = XCBuildConfiguration; 444 | baseConfigurationReference = 28C5446E3D304E183B8E9B04 /* Pods.release.xcconfig */; 445 | buildSettings = { 446 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 447 | CLANG_ENABLE_MODULES = YES; 448 | CODE_SIGN_IDENTITY = "iPhone Developer: kaihong luo (H536M777VC)"; 449 | INFOPLIST_FILE = QRCodeByAVFoundation/Info.plist; 450 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 452 | PRODUCT_NAME = "$(TARGET_NAME)"; 453 | PROVISIONING_PROFILE = "b3912e16-814d-42a0-86b7-a7983b159c6a"; 454 | }; 455 | name = Release; 456 | }; 457 | A78B45C21B0C2DB60090941F /* Debug */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | BUNDLE_LOADER = "$(TEST_HOST)"; 461 | FRAMEWORK_SEARCH_PATHS = ( 462 | "$(SDKROOT)/Developer/Library/Frameworks", 463 | "$(inherited)", 464 | ); 465 | GCC_PREPROCESSOR_DEFINITIONS = ( 466 | "DEBUG=1", 467 | "$(inherited)", 468 | ); 469 | INFOPLIST_FILE = QRCodeByAVFoundationTests/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QRCodeByAVFoundation.app/QRCodeByAVFoundation"; 473 | }; 474 | name = Debug; 475 | }; 476 | A78B45C31B0C2DB60090941F /* Release */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | BUNDLE_LOADER = "$(TEST_HOST)"; 480 | FRAMEWORK_SEARCH_PATHS = ( 481 | "$(SDKROOT)/Developer/Library/Frameworks", 482 | "$(inherited)", 483 | ); 484 | INFOPLIST_FILE = QRCodeByAVFoundationTests/Info.plist; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 486 | PRODUCT_NAME = "$(TARGET_NAME)"; 487 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QRCodeByAVFoundation.app/QRCodeByAVFoundation"; 488 | }; 489 | name = Release; 490 | }; 491 | /* End XCBuildConfiguration section */ 492 | 493 | /* Begin XCConfigurationList section */ 494 | A78B459A1B0C2DB60090941F /* Build configuration list for PBXProject "QRCodeByAVFoundation" */ = { 495 | isa = XCConfigurationList; 496 | buildConfigurations = ( 497 | A78B45BC1B0C2DB60090941F /* Debug */, 498 | A78B45BD1B0C2DB60090941F /* Release */, 499 | ); 500 | defaultConfigurationIsVisible = 0; 501 | defaultConfigurationName = Release; 502 | }; 503 | A78B45BE1B0C2DB60090941F /* Build configuration list for PBXNativeTarget "QRCodeByAVFoundation" */ = { 504 | isa = XCConfigurationList; 505 | buildConfigurations = ( 506 | A78B45BF1B0C2DB60090941F /* Debug */, 507 | A78B45C01B0C2DB60090941F /* Release */, 508 | ); 509 | defaultConfigurationIsVisible = 0; 510 | defaultConfigurationName = Release; 511 | }; 512 | A78B45C11B0C2DB60090941F /* Build configuration list for PBXNativeTarget "QRCodeByAVFoundationTests" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | A78B45C21B0C2DB60090941F /* Debug */, 516 | A78B45C31B0C2DB60090941F /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | defaultConfigurationName = Release; 520 | }; 521 | /* End XCConfigurationList section */ 522 | }; 523 | rootObject = A78B45971B0C2DB60090941F /* Project object */; 524 | } 525 | -------------------------------------------------------------------------------- /Pods/SnapKit/Source/ConstraintDescription.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SnapKit 3 | // 4 | // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #if os(iOS) 25 | import UIKit 26 | #else 27 | import AppKit 28 | #endif 29 | 30 | /** 31 | Used to expose the final API of a `ConstraintDescription` which allows getting a constraint from it 32 | */ 33 | public protocol ConstraintDescriptionFinalizable: class { 34 | 35 | var constraint: Constraint { get } 36 | 37 | } 38 | 39 | /** 40 | Used to expose priority APIs 41 | */ 42 | public protocol ConstraintDescriptionPriortizable: ConstraintDescriptionFinalizable { 43 | 44 | func priority(priority: Float) -> ConstraintDescriptionFinalizable 45 | func priority(priority: Double) -> ConstraintDescriptionFinalizable 46 | func priority(priority: CGFloat) -> ConstraintDescriptionFinalizable 47 | func priority(priority: UInt) -> ConstraintDescriptionFinalizable 48 | func priority(priority: Int) -> ConstraintDescriptionFinalizable 49 | func priorityRequired() -> ConstraintDescriptionFinalizable 50 | func priorityHigh() -> ConstraintDescriptionFinalizable 51 | func priorityMedium() -> ConstraintDescriptionFinalizable 52 | func priorityLow() -> ConstraintDescriptionFinalizable 53 | } 54 | 55 | /** 56 | Used to expose multiplier & constant APIs 57 | */ 58 | public protocol ConstraintDescriptionEditable: ConstraintDescriptionPriortizable { 59 | 60 | func multipliedBy(amount: Float) -> ConstraintDescriptionEditable 61 | func multipliedBy(amount: Double) -> ConstraintDescriptionEditable 62 | func multipliedBy(amount: CGFloat) -> ConstraintDescriptionEditable 63 | func multipliedBy(amount: Int) -> ConstraintDescriptionEditable 64 | func multipliedBy(amount: UInt) -> ConstraintDescriptionEditable 65 | 66 | func dividedBy(amount: Float) -> ConstraintDescriptionEditable 67 | func dividedBy(amount: Double) -> ConstraintDescriptionEditable 68 | func dividedBy(amount: CGFloat) -> ConstraintDescriptionEditable 69 | func dividedBy(amount: Int) -> ConstraintDescriptionEditable 70 | func dividedBy(amount: UInt) -> ConstraintDescriptionEditable 71 | 72 | func offset(amount: Float) -> ConstraintDescriptionEditable 73 | func offset(amount: Double) -> ConstraintDescriptionEditable 74 | func offset(amount: CGFloat) -> ConstraintDescriptionEditable 75 | func offset(amount: Int) -> ConstraintDescriptionEditable 76 | func offset(amount: UInt) -> ConstraintDescriptionEditable 77 | func offset(amount: CGPoint) -> ConstraintDescriptionEditable 78 | func offset(amount: CGSize) -> ConstraintDescriptionEditable 79 | func offset(amount: EdgeInsets) -> ConstraintDescriptionEditable 80 | 81 | func insets(amount: EdgeInsets) -> ConstraintDescriptionEditable 82 | } 83 | 84 | /** 85 | Used to expose relation APIs 86 | */ 87 | public protocol ConstraintDescriptionRelatable: class { 88 | 89 | func equalTo(other: ConstraintItem) -> ConstraintDescriptionEditable 90 | func equalTo(other: View) -> ConstraintDescriptionEditable 91 | #if os(iOS) 92 | func equalTo(other: UILayoutSupport) -> ConstraintDescriptionEditable 93 | #endif 94 | func equalTo(other: Float) -> ConstraintDescriptionEditable 95 | func equalTo(other: Double) -> ConstraintDescriptionEditable 96 | func equalTo(other: CGFloat) -> ConstraintDescriptionEditable 97 | func equalTo(other: Int) -> ConstraintDescriptionEditable 98 | func equalTo(other: UInt) -> ConstraintDescriptionEditable 99 | func equalTo(other: CGSize) -> ConstraintDescriptionEditable 100 | func equalTo(other: CGPoint) -> ConstraintDescriptionEditable 101 | func equalTo(other: EdgeInsets) -> ConstraintDescriptionEditable 102 | 103 | func lessThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionEditable 104 | func lessThanOrEqualTo(other: View) -> ConstraintDescriptionEditable 105 | #if os(iOS) 106 | func lessThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionEditable 107 | #endif 108 | func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable 109 | func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable 110 | func lessThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable 111 | func lessThanOrEqualTo(other: Int) -> ConstraintDescriptionEditable 112 | func lessThanOrEqualTo(other: UInt) -> ConstraintDescriptionEditable 113 | func lessThanOrEqualTo(other: CGSize) -> ConstraintDescriptionEditable 114 | func lessThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionEditable 115 | func lessThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionEditable 116 | 117 | func greaterThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionEditable 118 | func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionEditable 119 | #if os(iOS) 120 | func greaterThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionEditable 121 | #endif 122 | func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable 123 | func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable 124 | func greaterThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable 125 | func greaterThanOrEqualTo(other: Int) -> ConstraintDescriptionEditable 126 | func greaterThanOrEqualTo(other: UInt) -> ConstraintDescriptionEditable 127 | func greaterThanOrEqualTo(other: CGSize) -> ConstraintDescriptionEditable 128 | func greaterThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionEditable 129 | func greaterThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionEditable 130 | 131 | } 132 | 133 | /** 134 | Used to expose chaining APIs 135 | */ 136 | public protocol ConstraintDescriptionExtendable: ConstraintDescriptionRelatable { 137 | 138 | var left: ConstraintDescriptionExtendable { get } 139 | var top: ConstraintDescriptionExtendable { get } 140 | var bottom: ConstraintDescriptionExtendable { get } 141 | var right: ConstraintDescriptionExtendable { get } 142 | var leading: ConstraintDescriptionExtendable { get } 143 | var trailing: ConstraintDescriptionExtendable { get } 144 | var width: ConstraintDescriptionExtendable { get } 145 | var height: ConstraintDescriptionExtendable { get } 146 | var centerX: ConstraintDescriptionExtendable { get } 147 | var centerY: ConstraintDescriptionExtendable { get } 148 | var baseline: ConstraintDescriptionExtendable { get } 149 | 150 | #if os(iOS) 151 | var firstBaseline: ConstraintDescriptionExtendable { get } 152 | var leftMargin: ConstraintDescriptionExtendable { get } 153 | var rightMargin: ConstraintDescriptionExtendable { get } 154 | var topMargin: ConstraintDescriptionExtendable { get } 155 | var bottomMargin: ConstraintDescriptionExtendable { get } 156 | var leadingMargin: ConstraintDescriptionExtendable { get } 157 | var trailingMargin: ConstraintDescriptionExtendable { get } 158 | var centerXWithinMargins: ConstraintDescriptionExtendable { get } 159 | var centerYWithinMargins: ConstraintDescriptionExtendable { get } 160 | #endif 161 | } 162 | 163 | /** 164 | Used to internally manage building constraint 165 | */ 166 | final internal class ConstraintDescription: ConstraintDescriptionExtendable, ConstraintDescriptionEditable, ConstraintDescriptionFinalizable { 167 | 168 | internal var left: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Left) } 169 | internal var top: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Top) } 170 | internal var right: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Right) } 171 | internal var bottom: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Bottom) } 172 | internal var leading: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Leading) } 173 | internal var trailing: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Trailing) } 174 | internal var width: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Width) } 175 | internal var height: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Height) } 176 | internal var centerX: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterX) } 177 | internal var centerY: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterY) } 178 | internal var baseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Baseline) } 179 | 180 | #if os(iOS) 181 | internal var firstBaseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.FirstBaseline) } 182 | internal var leftMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.LeftMargin) } 183 | internal var rightMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.RightMargin) } 184 | internal var topMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.TopMargin) } 185 | internal var bottomMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.BottomMargin) } 186 | internal var leadingMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.LeadingMargin) } 187 | internal var trailingMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.TrailingMargin) } 188 | internal var centerXWithinMargins: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterXWithinMargins) } 189 | internal var centerYWithinMargins: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterYWithinMargins) } 190 | #endif 191 | 192 | // MARK: initializer 193 | 194 | init(fromItem: ConstraintItem) { 195 | self.fromItem = fromItem 196 | self.toItem = ConstraintItem(object: nil, attributes: ConstraintAttributes.None) 197 | } 198 | 199 | // MARK: equalTo 200 | 201 | internal func equalTo(other: ConstraintItem) -> ConstraintDescriptionEditable { 202 | return self.constrainTo(other, relation: .Equal) 203 | } 204 | internal func equalTo(other: View) -> ConstraintDescriptionEditable { 205 | return self.constrainTo(other, relation: .Equal) 206 | } 207 | #if os(iOS) 208 | internal func equalTo(other: UILayoutSupport) -> ConstraintDescriptionEditable { 209 | return self.constrainTo(other, relation: .Equal) 210 | } 211 | #endif 212 | internal func equalTo(other: Float) -> ConstraintDescriptionEditable { 213 | return self.constrainTo(other, relation: .Equal) 214 | } 215 | internal func equalTo(other: Double) -> ConstraintDescriptionEditable { 216 | return self.constrainTo(Float(other), relation: .Equal) 217 | } 218 | internal func equalTo(other: CGFloat) -> ConstraintDescriptionEditable { 219 | return self.constrainTo(Float(other), relation: .Equal) 220 | } 221 | internal func equalTo(other: Int) -> ConstraintDescriptionEditable { 222 | return self.constrainTo(Float(other), relation: .Equal) 223 | } 224 | internal func equalTo(other: UInt) -> ConstraintDescriptionEditable { 225 | return self.constrainTo(Float(other), relation: .Equal) 226 | } 227 | internal func equalTo(other: CGSize) -> ConstraintDescriptionEditable { 228 | return self.constrainTo(other, relation: .Equal) 229 | } 230 | internal func equalTo(other: CGPoint) -> ConstraintDescriptionEditable { 231 | return self.constrainTo(other, relation: .Equal) 232 | } 233 | internal func equalTo(other: EdgeInsets) -> ConstraintDescriptionEditable { 234 | return self.constrainTo(other, relation: .Equal) 235 | } 236 | 237 | // MARK: lessThanOrEqualTo 238 | 239 | internal func lessThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionEditable { 240 | return self.constrainTo(other, relation: .LessThanOrEqualTo) 241 | } 242 | internal func lessThanOrEqualTo(other: View) -> ConstraintDescriptionEditable { 243 | return self.constrainTo(other, relation: .LessThanOrEqualTo) 244 | } 245 | #if os(iOS) 246 | internal func lessThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionEditable { 247 | return self.constrainTo(other, relation: .LessThanOrEqualTo) 248 | } 249 | #endif 250 | internal func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable { 251 | return self.constrainTo(other, relation: .LessThanOrEqualTo) 252 | } 253 | internal func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable { 254 | return self.constrainTo(Float(other), relation: .LessThanOrEqualTo) 255 | } 256 | internal func lessThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable { 257 | return self.constrainTo(Float(other), relation: .LessThanOrEqualTo) 258 | } 259 | internal func lessThanOrEqualTo(other: Int) -> ConstraintDescriptionEditable { 260 | return self.constrainTo(Float(other), relation: .LessThanOrEqualTo) 261 | } 262 | internal func lessThanOrEqualTo(other: UInt) -> ConstraintDescriptionEditable { 263 | return self.constrainTo(Float(other), relation: .LessThanOrEqualTo) 264 | } 265 | internal func lessThanOrEqualTo(other: CGSize) -> ConstraintDescriptionEditable { 266 | return self.constrainTo(other, relation: .LessThanOrEqualTo) 267 | } 268 | internal func lessThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionEditable { 269 | return self.constrainTo(other, relation: .LessThanOrEqualTo) 270 | } 271 | internal func lessThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionEditable { 272 | return self.constrainTo(other, relation: .LessThanOrEqualTo) 273 | } 274 | 275 | // MARK: greaterThanOrEqualTo 276 | 277 | internal func greaterThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionEditable { 278 | return self.constrainTo(other, relation: .GreaterThanOrEqualTo) 279 | } 280 | internal func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionEditable { 281 | return self.constrainTo(other, relation: .GreaterThanOrEqualTo) 282 | } 283 | #if os(iOS) 284 | internal func greaterThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionEditable { 285 | return self.constrainTo(other, relation: .GreaterThanOrEqualTo) 286 | } 287 | #endif 288 | internal func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionEditable { 289 | return self.constrainTo(other, relation: .GreaterThanOrEqualTo) 290 | } 291 | internal func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionEditable { 292 | return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo) 293 | } 294 | internal func greaterThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionEditable { 295 | return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo) 296 | } 297 | internal func greaterThanOrEqualTo(other: Int) -> ConstraintDescriptionEditable { 298 | return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo) 299 | } 300 | internal func greaterThanOrEqualTo(other: UInt) -> ConstraintDescriptionEditable { 301 | return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo) 302 | } 303 | internal func greaterThanOrEqualTo(other: CGSize) -> ConstraintDescriptionEditable { 304 | return self.constrainTo(other, relation: .GreaterThanOrEqualTo) 305 | } 306 | internal func greaterThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionEditable { 307 | return self.constrainTo(other, relation: .GreaterThanOrEqualTo) 308 | } 309 | internal func greaterThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionEditable { 310 | return self.constrainTo(other, relation: .GreaterThanOrEqualTo) 311 | } 312 | 313 | // MARK: multiplier 314 | 315 | internal func multipliedBy(amount: Float) -> ConstraintDescriptionEditable { 316 | self.multiplier = amount 317 | return self 318 | } 319 | internal func multipliedBy(amount: Double) -> ConstraintDescriptionEditable { 320 | return self.multipliedBy(Float(amount)) 321 | } 322 | internal func multipliedBy(amount: CGFloat) -> ConstraintDescriptionEditable { 323 | return self.multipliedBy(Float(amount)) 324 | } 325 | internal func multipliedBy(amount: Int) -> ConstraintDescriptionEditable { 326 | return self.multipliedBy(Float(amount)) 327 | } 328 | internal func multipliedBy(amount: UInt) -> ConstraintDescriptionEditable { 329 | return self.multipliedBy(Float(amount)) 330 | } 331 | 332 | internal func dividedBy(amount: Float) -> ConstraintDescriptionEditable { 333 | self.multiplier = 1.0 / amount; 334 | return self 335 | } 336 | internal func dividedBy(amount: Double) -> ConstraintDescriptionEditable { 337 | return self.dividedBy(Float(amount)) 338 | } 339 | internal func dividedBy(amount: CGFloat) -> ConstraintDescriptionEditable { 340 | return self.dividedBy(Float(amount)) 341 | } 342 | internal func dividedBy(amount: Int) -> ConstraintDescriptionEditable { 343 | return self.dividedBy(Float(amount)) 344 | } 345 | internal func dividedBy(amount: UInt) -> ConstraintDescriptionEditable { 346 | return self.dividedBy(Float(amount)) 347 | } 348 | 349 | // MARK: offset 350 | 351 | internal func offset(amount: Float) -> ConstraintDescriptionEditable { 352 | self.constant = amount 353 | return self 354 | } 355 | internal func offset(amount: Double) -> ConstraintDescriptionEditable { 356 | return self.offset(Float(amount)) 357 | } 358 | internal func offset(amount: CGFloat) -> ConstraintDescriptionEditable { 359 | return self.offset(Float(amount)) 360 | } 361 | internal func offset(amount: Int) -> ConstraintDescriptionEditable { 362 | return self.offset(Float(amount)) 363 | } 364 | internal func offset(amount: UInt) -> ConstraintDescriptionEditable { 365 | return self.offset(Float(amount)) 366 | } 367 | internal func offset(amount: CGPoint) -> ConstraintDescriptionEditable { 368 | self.constant = amount 369 | return self 370 | } 371 | internal func offset(amount: CGSize) -> ConstraintDescriptionEditable { 372 | self.constant = amount 373 | return self 374 | } 375 | internal func offset(amount: EdgeInsets) -> ConstraintDescriptionEditable { 376 | self.constant = amount 377 | return self 378 | } 379 | 380 | // MARK: insets 381 | 382 | internal func insets(amount: EdgeInsets) -> ConstraintDescriptionEditable { 383 | self.constant = EdgeInsets(top: amount.top, left: amount.left, bottom: -amount.bottom, right: -amount.right) 384 | return self 385 | } 386 | 387 | // MARK: priority 388 | 389 | internal func priority(priority: Float) -> ConstraintDescriptionFinalizable { 390 | self.priority = priority 391 | return self 392 | } 393 | internal func priority(priority: Double) -> ConstraintDescriptionFinalizable { 394 | return self.priority(Float(priority)) 395 | } 396 | internal func priority(priority: CGFloat) -> ConstraintDescriptionFinalizable { 397 | return self.priority(Float(priority)) 398 | } 399 | func priority(priority: UInt) -> ConstraintDescriptionFinalizable { 400 | return self.priority(Float(priority)) 401 | } 402 | internal func priority(priority: Int) -> ConstraintDescriptionFinalizable { 403 | return self.priority(Float(priority)) 404 | } 405 | internal func priorityRequired() -> ConstraintDescriptionFinalizable { 406 | return self.priority(1000.0) 407 | } 408 | internal func priorityHigh() -> ConstraintDescriptionFinalizable { 409 | return self.priority(750.0) 410 | } 411 | internal func priorityMedium() -> ConstraintDescriptionFinalizable { 412 | #if os(iOS) 413 | return self.priority(500.0) 414 | #else 415 | return self.priority(501.0) 416 | #endif 417 | } 418 | internal func priorityLow() -> ConstraintDescriptionFinalizable { 419 | return self.priority(250.0) 420 | } 421 | 422 | // MARK: Constraint 423 | 424 | internal var constraint: Constraint { 425 | if self.concreteConstraint == nil { 426 | if self.relation == nil { 427 | fatalError("Attempting to create a constraint from a ConstraintDescription before it has been fully chained.") 428 | } 429 | self.concreteConstraint = ConcreteConstraint( 430 | fromItem: self.fromItem, 431 | toItem: self.toItem, 432 | relation: self.relation!, 433 | constant: self.constant, 434 | multiplier: self.multiplier, 435 | priority: self.priority) 436 | } 437 | return self.concreteConstraint! 438 | } 439 | 440 | // MARK: Private 441 | 442 | private let fromItem: ConstraintItem 443 | private var toItem: ConstraintItem { 444 | willSet { 445 | if self.concreteConstraint != nil { 446 | fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.") 447 | } 448 | } 449 | } 450 | private var relation: ConstraintRelation? { 451 | willSet { 452 | if self.concreteConstraint != nil { 453 | fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.") 454 | } 455 | } 456 | } 457 | private var constant: Any = Float(0.0) { 458 | willSet { 459 | if self.concreteConstraint != nil { 460 | fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.") 461 | } 462 | } 463 | } 464 | private var multiplier: Float = 1.0 { 465 | willSet { 466 | if self.concreteConstraint != nil { 467 | fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.") 468 | } 469 | } 470 | } 471 | private var priority: Float = 1000.0 { 472 | willSet { 473 | if self.concreteConstraint != nil { 474 | fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.") 475 | } 476 | } 477 | } 478 | private var concreteConstraint: ConcreteConstraint? = nil 479 | 480 | private func addConstraint(attributes: ConstraintAttributes) -> ConstraintDescription { 481 | if self.relation == nil { 482 | self.fromItem.attributes += attributes 483 | } 484 | return self 485 | } 486 | 487 | private func constrainTo(other: ConstraintItem, relation: ConstraintRelation) -> ConstraintDescription { 488 | if other.attributes != ConstraintAttributes.None { 489 | let toLayoutAttributes = other.attributes.layoutAttributes 490 | if toLayoutAttributes.count > 1 { 491 | let fromLayoutAttributes = self.fromItem.attributes.layoutAttributes 492 | if toLayoutAttributes != fromLayoutAttributes { 493 | NSException(name: "Invalid Constraint", reason: "Cannot constrain to multiple non identical attributes", userInfo: nil).raise() 494 | return self 495 | } 496 | other.attributes = ConstraintAttributes.None 497 | } 498 | } 499 | self.toItem = other 500 | self.relation = relation 501 | return self 502 | } 503 | 504 | private func constrainTo(other: View, relation: ConstraintRelation) -> ConstraintDescription { 505 | return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation) 506 | } 507 | 508 | #if os(iOS) 509 | 510 | private func constrainTo(other: UILayoutSupport, relation: ConstraintRelation) -> ConstraintDescription { 511 | return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation) 512 | } 513 | 514 | #endif 515 | 516 | private func constrainTo(other: Float, relation: ConstraintRelation) -> ConstraintDescription { 517 | self.constant = other 518 | return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation) 519 | } 520 | 521 | private func constrainTo(other: Double, relation: ConstraintRelation) -> ConstraintDescription { 522 | self.constant = other 523 | return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation) 524 | } 525 | 526 | private func constrainTo(other: CGSize, relation: ConstraintRelation) -> ConstraintDescription { 527 | self.constant = other 528 | return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation) 529 | } 530 | 531 | private func constrainTo(other: CGPoint, relation: ConstraintRelation) -> ConstraintDescription { 532 | self.constant = other 533 | return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation) 534 | } 535 | 536 | private func constrainTo(other: EdgeInsets, relation: ConstraintRelation) -> ConstraintDescription { 537 | self.constant = other 538 | return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation) 539 | } 540 | } --------------------------------------------------------------------------------