├── .gitignore ├── .swift-version ├── LICENSE ├── README.md ├── Ruler.podspec ├── Ruler ├── Info.plist ├── Ruler.h └── Ruler.swift ├── SizeMatters.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── Ruler.xcscheme └── SizeMatters ├── AppDelegate.swift ├── Base.lproj ├── LaunchScreen.xib └── Main.storyboard ├── Images.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Info.plist └── ViewController.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # OS X 21 | .DS_Store 22 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.2 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2018 nixzhu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 |

5 | 6 | # Ruler 7 | 8 | In some cases, we need to distinguish between different devices to set UI, but Adaptive Layout can not do that. So, there is a Ruler. 9 | 10 | ## Requirements 11 | 12 | Swift 4, iOS 8.0 13 | 14 | (Swift 3, use version 1.0.1) 15 | 16 | ## Example 17 | 18 | If we only consider iPhone's width, iPhone 5 has the same width of iPhone 4s, iPhone 6 has a bigger width, iPhone 6 Plus' width even bigger than iPhone 6, and iPhone X's width is the biggest. Only four widths. 19 | 20 | But if we consider full screen size of iPhone, there are five models, because iPhone 5's height is different from iPhone 4s'. 21 | 22 | If our app is universal, we need consider iPad, there are two models (in points). 23 | 24 | So all we need consider five cases as follows: 25 | 26 | ```swift 27 | enum Ruler { 28 | case iPhoneHorizontal(T, T, T) 29 | case iPhoneVertical(T, T, T, T, T) 30 | case iPad(T, T) 31 | case universalHorizontal(T, T, T, T, T) 32 | case universalVertical(T, T, T, T, T, T, T) 33 | } 34 | ``` 35 | 36 | In real world (thanks generics, Ruler can match anything for different sizes of iOS devices): 37 | 38 | ```swift 39 | import Ruler 40 | ``` 41 | 42 | ```swift 43 | // size, off course 44 | 45 | let width = Ruler.iPhoneHorizontal(10, 20, 30).value 46 | let height = Ruler.iPhoneVertical(5, 10, 20, 30, 40).value 47 | 48 | // or color 49 | 50 | colorView.backgroundColor = Ruler.universalVertical(UIColor.black, UIColor.red, UIColor.blue, UIColor.green, UIColor.yellow, UIColor.purple, UIColor.cyan).value 51 | 52 | // even closures 53 | 54 | typealias Greeting = () -> Void 55 | 56 | let greeting: Greeting = Ruler.universalVertical( 57 | { print("Hello!") }, 58 | { print("Hi!") }, 59 | { print("How are you!") }, 60 | { print("How do you do!") }, 61 | { print("好久不见!") }, 62 | { print("你好!") }, 63 | { print("很高兴见到你!") }).value 64 | 65 | greeting() 66 | 67 | // ... 68 | ``` 69 | 70 | ### Special offer 71 | 72 | Detect if this device is an iPhone X: 73 | 74 | ``` swift 75 | if ScreenModel.isPhoneX { 76 | print("It's an iPhone X. You're rich!") 77 | } 78 | ``` 79 | 80 | ## Installation 81 | 82 | Feel free to drag `Ruler.swift` to your iOS Project. But it's recommended to use Carthage (or CocoaPods). 83 | 84 | ### Carthage 85 | 86 | ```ogdl 87 | github "nixzhu/Ruler" 88 | ``` 89 | 90 | #### CocoaPods 91 | 92 | ```ruby 93 | pod 'Ruler' 94 | ``` 95 | 96 | # Contact 97 | 98 | NIX [@nixzhu](https://twitter.com/nixzhu) 99 | 100 | ## License 101 | 102 | Ruler is available under the MIT license. See the LICENSE file for more info. 103 | -------------------------------------------------------------------------------- /Ruler.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "Ruler" 4 | s.version = "3.0.0" 5 | s.summary = "Size matters, you need a ruler." 6 | 7 | s.description = <<-DESC 8 | In some cases, we need to distinguish between different devices 9 | to set UI, but Adaptive Layout can not do that. So, there is a Ruler. 10 | DESC 11 | 12 | s.homepage = "https://github.com/nixzhu/Ruler" 13 | 14 | s.license = { :type => "MIT", :file => "LICENSE" } 15 | 16 | s.authors = { "nixzhu" => "zhuhongxu@gmail.com" } 17 | s.social_media_url = "https://twitter.com/nixzhu" 18 | 19 | s.ios.deployment_target = "8.0" 20 | 21 | s.source = { :git => "https://github.com/nixzhu/Ruler.git", :tag => s.version } 22 | s.source_files = "Ruler/*.swift" 23 | s.requires_arc = true 24 | 25 | end 26 | -------------------------------------------------------------------------------- /Ruler/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Ruler/Ruler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Ruler.h 3 | // Ruler 4 | // 5 | // Created by NIX on 15/7/22. 6 | // Copyright (c) 2015年 nixWork. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Ruler. 12 | FOUNDATION_EXPORT double RulerVersionNumber; 13 | 14 | //! Project version string for Ruler. 15 | FOUNDATION_EXPORT const unsigned char RulerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Ruler/Ruler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Ruler.swift 3 | // Ruler 4 | // 5 | // Created by NIX on 15/7/22. 6 | // Copyright (c) 2015年 nixWork. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public enum ScreenModel { 12 | 13 | public enum ClassicModel { 14 | case inch35 15 | case inch4 16 | } 17 | 18 | case classic(ClassicModel) 19 | case bigger 20 | case biggerPlus 21 | case x 22 | case xMax 23 | 24 | public enum PadModel { 25 | case normal 26 | case pro 27 | } 28 | case iPad(PadModel) 29 | } 30 | 31 | private let screenModel: ScreenModel = { 32 | let screen = UIScreen.main 33 | let height = max(screen.bounds.width, screen.bounds.height) 34 | switch height { 35 | case 480: 36 | return .classic(.inch35) 37 | case 568: 38 | return .classic(.inch4) 39 | case 667: 40 | return .bigger 41 | case 736, 1920: 42 | return .biggerPlus 43 | case 812: 44 | return .x 45 | case 896: 46 | return .xMax 47 | case 1024: 48 | return .iPad(.normal) 49 | case 1112, 1366: 50 | return .iPad(.pro) 51 | default: 52 | print("Warning: Can NOT detect screenModel! bounds: \(screen.bounds) nativeScale: \(screen.nativeScale)") 53 | return .bigger // Default 54 | } 55 | }() 56 | 57 | public enum Ruler { 58 | 59 | case iPhoneHorizontal(T, T, T) 60 | case iPhoneVertical(T, T, T, T, T, T) 61 | case iPad(T, T) 62 | case universalHorizontal(T, T, T, T, T) 63 | case universalVertical(T, T, T, T, T, T, T, T) 64 | 65 | public var value: T { 66 | switch self { 67 | case let .iPhoneHorizontal(classic, bigger, biggerPlus): 68 | switch screenModel { 69 | case .classic: 70 | return classic 71 | case .bigger: 72 | return bigger 73 | case .biggerPlus: 74 | return biggerPlus 75 | case .x: 76 | return bigger 77 | case .xMax: 78 | return biggerPlus 79 | default: 80 | return biggerPlus 81 | } 82 | case let .iPhoneVertical(inch35, inch4, bigger, biggerPlus, x, xMax): 83 | switch screenModel { 84 | case .classic(let model): 85 | switch model { 86 | case .inch35: 87 | return inch35 88 | case .inch4: 89 | return inch4 90 | } 91 | case .bigger: 92 | return bigger 93 | case .biggerPlus: 94 | return biggerPlus 95 | case .x: 96 | return x 97 | case .xMax: 98 | return xMax 99 | default: 100 | return biggerPlus 101 | } 102 | case let .iPad(normal, pro): 103 | switch screenModel { 104 | case .iPad(let model): 105 | switch model { 106 | case .normal: 107 | return normal 108 | case .pro: 109 | return pro 110 | } 111 | default: 112 | return normal 113 | } 114 | case let .universalHorizontal(classic, bigger, biggerPlus, iPadNormal, iPadPro): 115 | switch screenModel { 116 | case .classic: 117 | return classic 118 | case .bigger: 119 | return bigger 120 | case .biggerPlus: 121 | return biggerPlus 122 | case .x: 123 | return bigger 124 | case .xMax: 125 | return biggerPlus 126 | case .iPad(let model): 127 | switch model { 128 | case .normal: 129 | return iPadNormal 130 | case .pro: 131 | return iPadPro 132 | } 133 | } 134 | case let .universalVertical(inch35, inch4, bigger, biggerPlus, x, xMax, iPadNormal, iPadPro): 135 | switch screenModel { 136 | case .classic(let model): 137 | switch model { 138 | case .inch35: 139 | return inch35 140 | case .inch4: 141 | return inch4 142 | } 143 | case .bigger: 144 | return bigger 145 | case .biggerPlus: 146 | return biggerPlus 147 | case .x: 148 | return x 149 | case .xMax: 150 | return xMax 151 | case .iPad(let model): 152 | switch model { 153 | case .normal: 154 | return iPadNormal 155 | case .pro: 156 | return iPadPro 157 | } 158 | } 159 | } 160 | } 161 | } 162 | 163 | extension ScreenModel { 164 | 165 | public static var isPhoneX: Bool { 166 | switch screenModel { 167 | case .x, .xMax: 168 | return true 169 | default: 170 | return false 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /SizeMatters.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5044BEBD1B5F731400930ADC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5044BEBC1B5F731400930ADC /* AppDelegate.swift */; }; 11 | 5044BEBF1B5F731400930ADC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5044BEBE1B5F731400930ADC /* ViewController.swift */; }; 12 | 5044BEC21B5F731400930ADC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5044BEC01B5F731400930ADC /* Main.storyboard */; }; 13 | 5044BEC41B5F731400930ADC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5044BEC31B5F731400930ADC /* Images.xcassets */; }; 14 | 5044BEC71B5F731400930ADC /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5044BEC51B5F731400930ADC /* LaunchScreen.xib */; }; 15 | 5044BEE61B5F73A500930ADC /* Ruler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5044BEE51B5F73A500930ADC /* Ruler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | 5044BEF81B5F73A500930ADC /* Ruler.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5044BEE11B5F73A500930ADC /* Ruler.framework */; }; 17 | 5044BEF91B5F73A500930ADC /* Ruler.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5044BEE11B5F73A500930ADC /* Ruler.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 5044BF041B5F890100930ADC /* Ruler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5044BF031B5F890100930ADC /* Ruler.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 5044BEF61B5F73A500930ADC /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 5044BEAF1B5F731400930ADC /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 5044BEE01B5F73A500930ADC; 27 | remoteInfo = Ruler; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXCopyFilesBuildPhase section */ 32 | 5044BEFF1B5F73A500930ADC /* Embed Frameworks */ = { 33 | isa = PBXCopyFilesBuildPhase; 34 | buildActionMask = 2147483647; 35 | dstPath = ""; 36 | dstSubfolderSpec = 10; 37 | files = ( 38 | 5044BEF91B5F73A500930ADC /* Ruler.framework in Embed Frameworks */, 39 | ); 40 | name = "Embed Frameworks"; 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXCopyFilesBuildPhase section */ 44 | 45 | /* Begin PBXFileReference section */ 46 | 5044BEB71B5F731400930ADC /* SizeMatters.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SizeMatters.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 5044BEBB1B5F731400930ADC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 5044BEBC1B5F731400930ADC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 49 | 5044BEBE1B5F731400930ADC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 50 | 5044BEC11B5F731400930ADC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 51 | 5044BEC31B5F731400930ADC /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 52 | 5044BEC61B5F731400930ADC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 53 | 5044BEE11B5F73A500930ADC /* Ruler.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Ruler.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 5044BEE41B5F73A500930ADC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 5044BEE51B5F73A500930ADC /* Ruler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Ruler.h; sourceTree = ""; }; 56 | 5044BF031B5F890100930ADC /* Ruler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Ruler.swift; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 5044BEB41B5F731400930ADC /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | 5044BEF81B5F73A500930ADC /* Ruler.framework in Frameworks */, 65 | ); 66 | runOnlyForDeploymentPostprocessing = 0; 67 | }; 68 | 5044BEDD1B5F73A500930ADC /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | /* End PBXFrameworksBuildPhase section */ 76 | 77 | /* Begin PBXGroup section */ 78 | 5044BEAE1B5F731400930ADC = { 79 | isa = PBXGroup; 80 | children = ( 81 | 5044BEB91B5F731400930ADC /* SizeMatters */, 82 | 5044BEE21B5F73A500930ADC /* Ruler */, 83 | 5044BEB81B5F731400930ADC /* Products */, 84 | ); 85 | sourceTree = ""; 86 | }; 87 | 5044BEB81B5F731400930ADC /* Products */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 5044BEB71B5F731400930ADC /* SizeMatters.app */, 91 | 5044BEE11B5F73A500930ADC /* Ruler.framework */, 92 | ); 93 | name = Products; 94 | sourceTree = ""; 95 | }; 96 | 5044BEB91B5F731400930ADC /* SizeMatters */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 5044BEBC1B5F731400930ADC /* AppDelegate.swift */, 100 | 5044BEBE1B5F731400930ADC /* ViewController.swift */, 101 | 5044BEC01B5F731400930ADC /* Main.storyboard */, 102 | 5044BEC31B5F731400930ADC /* Images.xcassets */, 103 | 5044BEC51B5F731400930ADC /* LaunchScreen.xib */, 104 | 5044BEBA1B5F731400930ADC /* Supporting Files */, 105 | ); 106 | path = SizeMatters; 107 | sourceTree = ""; 108 | }; 109 | 5044BEBA1B5F731400930ADC /* Supporting Files */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 5044BEBB1B5F731400930ADC /* Info.plist */, 113 | ); 114 | name = "Supporting Files"; 115 | sourceTree = ""; 116 | }; 117 | 5044BEE21B5F73A500930ADC /* Ruler */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 5044BEE51B5F73A500930ADC /* Ruler.h */, 121 | 5044BF031B5F890100930ADC /* Ruler.swift */, 122 | 5044BEE31B5F73A500930ADC /* Supporting Files */, 123 | ); 124 | path = Ruler; 125 | sourceTree = ""; 126 | }; 127 | 5044BEE31B5F73A500930ADC /* Supporting Files */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 5044BEE41B5F73A500930ADC /* Info.plist */, 131 | ); 132 | name = "Supporting Files"; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXHeadersBuildPhase section */ 138 | 5044BEDE1B5F73A500930ADC /* Headers */ = { 139 | isa = PBXHeadersBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | 5044BEE61B5F73A500930ADC /* Ruler.h in Headers */, 143 | ); 144 | runOnlyForDeploymentPostprocessing = 0; 145 | }; 146 | /* End PBXHeadersBuildPhase section */ 147 | 148 | /* Begin PBXNativeTarget section */ 149 | 5044BEB61B5F731400930ADC /* SizeMatters */ = { 150 | isa = PBXNativeTarget; 151 | buildConfigurationList = 5044BED61B5F731500930ADC /* Build configuration list for PBXNativeTarget "SizeMatters" */; 152 | buildPhases = ( 153 | 5044BEB31B5F731400930ADC /* Sources */, 154 | 5044BEB41B5F731400930ADC /* Frameworks */, 155 | 5044BEB51B5F731400930ADC /* Resources */, 156 | 5044BEFF1B5F73A500930ADC /* Embed Frameworks */, 157 | ); 158 | buildRules = ( 159 | ); 160 | dependencies = ( 161 | 5044BEF71B5F73A500930ADC /* PBXTargetDependency */, 162 | ); 163 | name = SizeMatters; 164 | productName = SizeMatters; 165 | productReference = 5044BEB71B5F731400930ADC /* SizeMatters.app */; 166 | productType = "com.apple.product-type.application"; 167 | }; 168 | 5044BEE01B5F73A500930ADC /* Ruler */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = 5044BEFE1B5F73A500930ADC /* Build configuration list for PBXNativeTarget "Ruler" */; 171 | buildPhases = ( 172 | 5044BEDC1B5F73A500930ADC /* Sources */, 173 | 5044BEDD1B5F73A500930ADC /* Frameworks */, 174 | 5044BEDE1B5F73A500930ADC /* Headers */, 175 | 5044BEDF1B5F73A500930ADC /* Resources */, 176 | ); 177 | buildRules = ( 178 | ); 179 | dependencies = ( 180 | ); 181 | name = Ruler; 182 | productName = Ruler; 183 | productReference = 5044BEE11B5F73A500930ADC /* Ruler.framework */; 184 | productType = "com.apple.product-type.framework"; 185 | }; 186 | /* End PBXNativeTarget section */ 187 | 188 | /* Begin PBXProject section */ 189 | 5044BEAF1B5F731400930ADC /* Project object */ = { 190 | isa = PBXProject; 191 | attributes = { 192 | LastSwiftMigration = 0700; 193 | LastSwiftUpdateCheck = 0700; 194 | LastUpgradeCheck = 0930; 195 | ORGANIZATIONNAME = nixWork; 196 | TargetAttributes = { 197 | 5044BEB61B5F731400930ADC = { 198 | CreatedOnToolsVersion = 6.4; 199 | DevelopmentTeam = 8D957V42M6; 200 | LastSwiftMigration = 0800; 201 | }; 202 | 5044BEE01B5F73A500930ADC = { 203 | CreatedOnToolsVersion = 6.4; 204 | LastSwiftMigration = 0800; 205 | }; 206 | }; 207 | }; 208 | buildConfigurationList = 5044BEB21B5F731400930ADC /* Build configuration list for PBXProject "SizeMatters" */; 209 | compatibilityVersion = "Xcode 3.2"; 210 | developmentRegion = English; 211 | hasScannedForEncodings = 0; 212 | knownRegions = ( 213 | en, 214 | Base, 215 | ); 216 | mainGroup = 5044BEAE1B5F731400930ADC; 217 | productRefGroup = 5044BEB81B5F731400930ADC /* Products */; 218 | projectDirPath = ""; 219 | projectRoot = ""; 220 | targets = ( 221 | 5044BEB61B5F731400930ADC /* SizeMatters */, 222 | 5044BEE01B5F73A500930ADC /* Ruler */, 223 | ); 224 | }; 225 | /* End PBXProject section */ 226 | 227 | /* Begin PBXResourcesBuildPhase section */ 228 | 5044BEB51B5F731400930ADC /* Resources */ = { 229 | isa = PBXResourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 5044BEC21B5F731400930ADC /* Main.storyboard in Resources */, 233 | 5044BEC71B5F731400930ADC /* LaunchScreen.xib in Resources */, 234 | 5044BEC41B5F731400930ADC /* Images.xcassets in Resources */, 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | }; 238 | 5044BEDF1B5F73A500930ADC /* Resources */ = { 239 | isa = PBXResourcesBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | ); 243 | runOnlyForDeploymentPostprocessing = 0; 244 | }; 245 | /* End PBXResourcesBuildPhase section */ 246 | 247 | /* Begin PBXSourcesBuildPhase section */ 248 | 5044BEB31B5F731400930ADC /* Sources */ = { 249 | isa = PBXSourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | 5044BEBF1B5F731400930ADC /* ViewController.swift in Sources */, 253 | 5044BEBD1B5F731400930ADC /* AppDelegate.swift in Sources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | 5044BEDC1B5F73A500930ADC /* Sources */ = { 258 | isa = PBXSourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | 5044BF041B5F890100930ADC /* Ruler.swift in Sources */, 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | }; 265 | /* End PBXSourcesBuildPhase section */ 266 | 267 | /* Begin PBXTargetDependency section */ 268 | 5044BEF71B5F73A500930ADC /* PBXTargetDependency */ = { 269 | isa = PBXTargetDependency; 270 | target = 5044BEE01B5F73A500930ADC /* Ruler */; 271 | targetProxy = 5044BEF61B5F73A500930ADC /* PBXContainerItemProxy */; 272 | }; 273 | /* End PBXTargetDependency section */ 274 | 275 | /* Begin PBXVariantGroup section */ 276 | 5044BEC01B5F731400930ADC /* Main.storyboard */ = { 277 | isa = PBXVariantGroup; 278 | children = ( 279 | 5044BEC11B5F731400930ADC /* Base */, 280 | ); 281 | name = Main.storyboard; 282 | sourceTree = ""; 283 | }; 284 | 5044BEC51B5F731400930ADC /* LaunchScreen.xib */ = { 285 | isa = PBXVariantGroup; 286 | children = ( 287 | 5044BEC61B5F731400930ADC /* Base */, 288 | ); 289 | name = LaunchScreen.xib; 290 | sourceTree = ""; 291 | }; 292 | /* End PBXVariantGroup section */ 293 | 294 | /* Begin XCBuildConfiguration section */ 295 | 5044BED41B5F731500930ADC /* Debug */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ALWAYS_SEARCH_USER_PATHS = NO; 299 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 300 | CLANG_CXX_LIBRARY = "libc++"; 301 | CLANG_ENABLE_MODULES = YES; 302 | CLANG_ENABLE_OBJC_ARC = YES; 303 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 304 | CLANG_WARN_BOOL_CONVERSION = YES; 305 | CLANG_WARN_COMMA = YES; 306 | CLANG_WARN_CONSTANT_CONVERSION = YES; 307 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 308 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 309 | CLANG_WARN_EMPTY_BODY = YES; 310 | CLANG_WARN_ENUM_CONVERSION = YES; 311 | CLANG_WARN_INFINITE_RECURSION = YES; 312 | CLANG_WARN_INT_CONVERSION = YES; 313 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 314 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 315 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 316 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 317 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 318 | CLANG_WARN_STRICT_PROTOTYPES = YES; 319 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 320 | CLANG_WARN_UNREACHABLE_CODE = YES; 321 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 322 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 323 | COPY_PHASE_STRIP = NO; 324 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 325 | ENABLE_STRICT_OBJC_MSGSEND = YES; 326 | ENABLE_TESTABILITY = YES; 327 | GCC_C_LANGUAGE_STANDARD = gnu99; 328 | GCC_DYNAMIC_NO_PIC = NO; 329 | GCC_NO_COMMON_BLOCKS = YES; 330 | GCC_OPTIMIZATION_LEVEL = 0; 331 | GCC_PREPROCESSOR_DEFINITIONS = ( 332 | "DEBUG=1", 333 | "$(inherited)", 334 | ); 335 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 336 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 337 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 338 | GCC_WARN_UNDECLARED_SELECTOR = YES; 339 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 340 | GCC_WARN_UNUSED_FUNCTION = YES; 341 | GCC_WARN_UNUSED_VARIABLE = YES; 342 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 343 | MTL_ENABLE_DEBUG_INFO = YES; 344 | ONLY_ACTIVE_ARCH = YES; 345 | SDKROOT = iphoneos; 346 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 347 | SWIFT_VERSION = 4.0; 348 | TARGETED_DEVICE_FAMILY = "1,2"; 349 | }; 350 | name = Debug; 351 | }; 352 | 5044BED51B5F731500930ADC /* Release */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ALWAYS_SEARCH_USER_PATHS = NO; 356 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 357 | CLANG_CXX_LIBRARY = "libc++"; 358 | CLANG_ENABLE_MODULES = YES; 359 | CLANG_ENABLE_OBJC_ARC = YES; 360 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 361 | CLANG_WARN_BOOL_CONVERSION = YES; 362 | CLANG_WARN_COMMA = YES; 363 | CLANG_WARN_CONSTANT_CONVERSION = YES; 364 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 365 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 366 | CLANG_WARN_EMPTY_BODY = YES; 367 | CLANG_WARN_ENUM_CONVERSION = YES; 368 | CLANG_WARN_INFINITE_RECURSION = YES; 369 | CLANG_WARN_INT_CONVERSION = YES; 370 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 371 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 372 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 373 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 374 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 375 | CLANG_WARN_STRICT_PROTOTYPES = YES; 376 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 377 | CLANG_WARN_UNREACHABLE_CODE = YES; 378 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 379 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 380 | COPY_PHASE_STRIP = NO; 381 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 382 | ENABLE_NS_ASSERTIONS = NO; 383 | ENABLE_STRICT_OBJC_MSGSEND = YES; 384 | GCC_C_LANGUAGE_STANDARD = gnu99; 385 | GCC_NO_COMMON_BLOCKS = YES; 386 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 387 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 388 | GCC_WARN_UNDECLARED_SELECTOR = YES; 389 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 390 | GCC_WARN_UNUSED_FUNCTION = YES; 391 | GCC_WARN_UNUSED_VARIABLE = YES; 392 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 393 | MTL_ENABLE_DEBUG_INFO = NO; 394 | SDKROOT = iphoneos; 395 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 396 | SWIFT_VERSION = 4.0; 397 | TARGETED_DEVICE_FAMILY = "1,2"; 398 | VALIDATE_PRODUCT = YES; 399 | }; 400 | name = Release; 401 | }; 402 | 5044BED71B5F731500930ADC /* Debug */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 406 | DEVELOPMENT_TEAM = 8D957V42M6; 407 | INFOPLIST_FILE = SizeMatters/Info.plist; 408 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 409 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 410 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)"; 411 | PRODUCT_NAME = "$(TARGET_NAME)"; 412 | SWIFT_VERSION = 4.0; 413 | }; 414 | name = Debug; 415 | }; 416 | 5044BED81B5F731500930ADC /* Release */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 420 | DEVELOPMENT_TEAM = 8D957V42M6; 421 | INFOPLIST_FILE = SizeMatters/Info.plist; 422 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 423 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 424 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)"; 425 | PRODUCT_NAME = "$(TARGET_NAME)"; 426 | SWIFT_VERSION = 4.0; 427 | }; 428 | name = Release; 429 | }; 430 | 5044BEFA1B5F73A500930ADC /* Debug */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | APPLICATION_EXTENSION_API_ONLY = YES; 434 | CLANG_ENABLE_MODULES = YES; 435 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 436 | CURRENT_PROJECT_VERSION = 1; 437 | DEFINES_MODULE = YES; 438 | DYLIB_COMPATIBILITY_VERSION = 1; 439 | DYLIB_CURRENT_VERSION = 1; 440 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 441 | GCC_PREPROCESSOR_DEFINITIONS = ( 442 | "DEBUG=1", 443 | "$(inherited)", 444 | ); 445 | INFOPLIST_FILE = Ruler/Info.plist; 446 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 447 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 448 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 449 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | SKIP_INSTALL = YES; 452 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 453 | SWIFT_VERSION = 4.0; 454 | VERSIONING_SYSTEM = "apple-generic"; 455 | VERSION_INFO_PREFIX = ""; 456 | }; 457 | name = Debug; 458 | }; 459 | 5044BEFB1B5F73A500930ADC /* Release */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | APPLICATION_EXTENSION_API_ONLY = YES; 463 | CLANG_ENABLE_MODULES = YES; 464 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 465 | CURRENT_PROJECT_VERSION = 1; 466 | DEFINES_MODULE = YES; 467 | DYLIB_COMPATIBILITY_VERSION = 1; 468 | DYLIB_CURRENT_VERSION = 1; 469 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 470 | INFOPLIST_FILE = Ruler/Info.plist; 471 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 472 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 473 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 474 | PRODUCT_BUNDLE_IDENTIFIER = "com.nixWork.$(PRODUCT_NAME:rfc1034identifier)"; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | SKIP_INSTALL = YES; 477 | SWIFT_VERSION = 4.0; 478 | VERSIONING_SYSTEM = "apple-generic"; 479 | VERSION_INFO_PREFIX = ""; 480 | }; 481 | name = Release; 482 | }; 483 | /* End XCBuildConfiguration section */ 484 | 485 | /* Begin XCConfigurationList section */ 486 | 5044BEB21B5F731400930ADC /* Build configuration list for PBXProject "SizeMatters" */ = { 487 | isa = XCConfigurationList; 488 | buildConfigurations = ( 489 | 5044BED41B5F731500930ADC /* Debug */, 490 | 5044BED51B5F731500930ADC /* Release */, 491 | ); 492 | defaultConfigurationIsVisible = 0; 493 | defaultConfigurationName = Release; 494 | }; 495 | 5044BED61B5F731500930ADC /* Build configuration list for PBXNativeTarget "SizeMatters" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 5044BED71B5F731500930ADC /* Debug */, 499 | 5044BED81B5F731500930ADC /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | 5044BEFE1B5F73A500930ADC /* Build configuration list for PBXNativeTarget "Ruler" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | 5044BEFA1B5F73A500930ADC /* Debug */, 508 | 5044BEFB1B5F73A500930ADC /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | defaultConfigurationName = Release; 512 | }; 513 | /* End XCConfigurationList section */ 514 | }; 515 | rootObject = 5044BEAF1B5F731400930ADC /* Project object */; 516 | } 517 | -------------------------------------------------------------------------------- /SizeMatters.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SizeMatters.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SizeMatters.xcodeproj/xcshareddata/xcschemes/Ruler.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /SizeMatters/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SizeMatters 4 | // 5 | // Created by NIX on 15/7/22. 6 | // Copyright (c) 2015年 nixWork. 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: [UIApplicationLaunchOptionsKey: Any]?) -> 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 | -------------------------------------------------------------------------------- /SizeMatters/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 | -------------------------------------------------------------------------------- /SizeMatters/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /SizeMatters/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /SizeMatters/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 3.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 25 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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SizeMatters/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SizeMatters 4 | // 5 | // Created by NIX on 15/7/22. 6 | // Copyright (c) 2015年 nixWork. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Ruler 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet weak var leftMargin: NSLayoutConstraint! 15 | @IBOutlet weak var topMargin: NSLayoutConstraint! 16 | 17 | @IBOutlet weak var colorView: UIView! 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | // set some constraints 23 | 24 | leftMargin.constant = Ruler.universalHorizontal(0, 20, 40, 60, 80).value 25 | topMargin.constant = Ruler.universalVertical(0, 20, 40, 60, 70, 80, 100).value 26 | 27 | // other test 28 | 29 | let width = Ruler.iPhoneHorizontal(10, 20, 30).value 30 | print("width = \(width)\n") 31 | 32 | let height = Ruler.iPhoneVertical(5, 10, 20, 30, 40).value 33 | print("height = \(height)\n") 34 | 35 | let iPadWidthOrHeight = Ruler.iPad(20, 50).value 36 | print("iPadWidthOrHeight = \(iPadWidthOrHeight)\n") 37 | 38 | let universalWidth = Ruler.universalHorizontal(10, 20, 30, 40, 60).value 39 | print("universalWidth = \(universalWidth)\n") 40 | 41 | let universalHeight = Ruler.universalVertical(5, 10, 20, 30, 40, 50, 60).value 42 | print("universalHeight = \(universalHeight)\n") 43 | 44 | // thanks generics, Ruler can match anything for different sizes of iOS devices, not just the length! 45 | 46 | colorView.backgroundColor = Ruler.universalVertical(UIColor.black, UIColor.red, UIColor.blue, UIColor.green, UIColor.yellow, UIColor.purple, UIColor.cyan).value 47 | 48 | typealias Greeting = () -> Void 49 | 50 | let greeting: Greeting = Ruler.universalVertical( 51 | { print("Hello!") }, 52 | { print("Hi!") }, 53 | { print("How are you!") }, 54 | { print("How do you do!") }, 55 | { print("好久不见!") }, 56 | { print("你好!") }, 57 | { print("很高兴见到你!") }).value 58 | 59 | greeting() 60 | 61 | if ScreenModel.isPhoneX { 62 | print("It's an iPhone X. You're rich!") 63 | } 64 | } 65 | } 66 | --------------------------------------------------------------------------------