├── .gitignore ├── HowColor.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── HowColor ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Controllers │ ├── GameViewController.swift │ └── ViewController.swift ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist └── Tools │ ├── Device.swift │ └── UserDefaults.swift ├── HowColorTests ├── HowColorTests.swift └── Info.plist ├── LICENSE └── README.md /.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 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /HowColor.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0D8E730D1B799F9500865BD5 /* Device.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D8E730C1B799F9500865BD5 /* Device.swift */; }; 11 | B96C5EB31B15F3680044DAD2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B96C5EB21B15F3680044DAD2 /* AppDelegate.swift */; }; 12 | B96C5EB81B15F3680044DAD2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B96C5EB61B15F3680044DAD2 /* Main.storyboard */; }; 13 | B96C5EBA1B15F3680044DAD2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B96C5EB91B15F3680044DAD2 /* Images.xcassets */; }; 14 | B96C5EBD1B15F3680044DAD2 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = B96C5EBB1B15F3680044DAD2 /* LaunchScreen.xib */; }; 15 | B96C5EC91B15F3680044DAD2 /* HowColorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B96C5EC81B15F3680044DAD2 /* HowColorTests.swift */; }; 16 | B96C5ED41B15F7BC0044DAD2 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B96C5ED31B15F7BC0044DAD2 /* UserDefaults.swift */; }; 17 | B96C5ED81B15FA830044DAD2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B96C5ED71B15FA830044DAD2 /* ViewController.swift */; }; 18 | B96C5EDA1B15FAA10044DAD2 /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B96C5ED91B15FAA10044DAD2 /* GameViewController.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | B96C5EC31B15F3680044DAD2 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = B96C5EA51B15F3670044DAD2 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = B96C5EAC1B15F3670044DAD2; 27 | remoteInfo = HowColor; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 0D8E730C1B799F9500865BD5 /* Device.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Device.swift; sourceTree = ""; }; 33 | B96C5EAD1B15F3670044DAD2 /* HowColor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HowColor.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | B96C5EB11B15F3680044DAD2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | B96C5EB21B15F3680044DAD2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 36 | B96C5EB71B15F3680044DAD2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | B96C5EB91B15F3680044DAD2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 38 | B96C5EBC1B15F3680044DAD2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 39 | B96C5EC21B15F3680044DAD2 /* HowColorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HowColorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | B96C5EC71B15F3680044DAD2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | B96C5EC81B15F3680044DAD2 /* HowColorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HowColorTests.swift; sourceTree = ""; }; 42 | B96C5ED31B15F7BC0044DAD2 /* UserDefaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = ""; }; 43 | B96C5ED71B15FA830044DAD2 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 44 | B96C5ED91B15FAA10044DAD2 /* GameViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | B96C5EAA1B15F3670044DAD2 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | B96C5EBF1B15F3680044DAD2 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | B96C5EA41B15F3670044DAD2 = { 66 | isa = PBXGroup; 67 | children = ( 68 | B96C5EAF1B15F3670044DAD2 /* HowColor */, 69 | B96C5EC51B15F3680044DAD2 /* HowColorTests */, 70 | B96C5EAE1B15F3670044DAD2 /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | B96C5EAE1B15F3670044DAD2 /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | B96C5EAD1B15F3670044DAD2 /* HowColor.app */, 78 | B96C5EC21B15F3680044DAD2 /* HowColorTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | B96C5EAF1B15F3670044DAD2 /* HowColor */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | B96C5ED61B15FA830044DAD2 /* Controllers */, 87 | B96C5ED21B15F7A80044DAD2 /* Tools */, 88 | B96C5EB21B15F3680044DAD2 /* AppDelegate.swift */, 89 | B96C5EB61B15F3680044DAD2 /* Main.storyboard */, 90 | B96C5EB91B15F3680044DAD2 /* Images.xcassets */, 91 | B96C5EBB1B15F3680044DAD2 /* LaunchScreen.xib */, 92 | B96C5EB01B15F3680044DAD2 /* Supporting Files */, 93 | ); 94 | path = HowColor; 95 | sourceTree = ""; 96 | }; 97 | B96C5EB01B15F3680044DAD2 /* Supporting Files */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | B96C5EB11B15F3680044DAD2 /* Info.plist */, 101 | ); 102 | name = "Supporting Files"; 103 | sourceTree = ""; 104 | }; 105 | B96C5EC51B15F3680044DAD2 /* HowColorTests */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | B96C5EC81B15F3680044DAD2 /* HowColorTests.swift */, 109 | B96C5EC61B15F3680044DAD2 /* Supporting Files */, 110 | ); 111 | path = HowColorTests; 112 | sourceTree = ""; 113 | }; 114 | B96C5EC61B15F3680044DAD2 /* Supporting Files */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | B96C5EC71B15F3680044DAD2 /* Info.plist */, 118 | ); 119 | name = "Supporting Files"; 120 | sourceTree = ""; 121 | }; 122 | B96C5ED21B15F7A80044DAD2 /* Tools */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | B96C5ED31B15F7BC0044DAD2 /* UserDefaults.swift */, 126 | 0D8E730C1B799F9500865BD5 /* Device.swift */, 127 | ); 128 | path = Tools; 129 | sourceTree = ""; 130 | }; 131 | B96C5ED61B15FA830044DAD2 /* Controllers */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | B96C5ED71B15FA830044DAD2 /* ViewController.swift */, 135 | B96C5ED91B15FAA10044DAD2 /* GameViewController.swift */, 136 | ); 137 | path = Controllers; 138 | sourceTree = ""; 139 | }; 140 | /* End PBXGroup section */ 141 | 142 | /* Begin PBXNativeTarget section */ 143 | B96C5EAC1B15F3670044DAD2 /* HowColor */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = B96C5ECC1B15F3680044DAD2 /* Build configuration list for PBXNativeTarget "HowColor" */; 146 | buildPhases = ( 147 | B96C5EA91B15F3670044DAD2 /* Sources */, 148 | B96C5EAA1B15F3670044DAD2 /* Frameworks */, 149 | B96C5EAB1B15F3670044DAD2 /* Resources */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = HowColor; 156 | productName = HowColor; 157 | productReference = B96C5EAD1B15F3670044DAD2 /* HowColor.app */; 158 | productType = "com.apple.product-type.application"; 159 | }; 160 | B96C5EC11B15F3680044DAD2 /* HowColorTests */ = { 161 | isa = PBXNativeTarget; 162 | buildConfigurationList = B96C5ECF1B15F3680044DAD2 /* Build configuration list for PBXNativeTarget "HowColorTests" */; 163 | buildPhases = ( 164 | B96C5EBE1B15F3680044DAD2 /* Sources */, 165 | B96C5EBF1B15F3680044DAD2 /* Frameworks */, 166 | B96C5EC01B15F3680044DAD2 /* Resources */, 167 | ); 168 | buildRules = ( 169 | ); 170 | dependencies = ( 171 | B96C5EC41B15F3680044DAD2 /* PBXTargetDependency */, 172 | ); 173 | name = HowColorTests; 174 | productName = HowColorTests; 175 | productReference = B96C5EC21B15F3680044DAD2 /* HowColorTests.xctest */; 176 | productType = "com.apple.product-type.bundle.unit-test"; 177 | }; 178 | /* End PBXNativeTarget section */ 179 | 180 | /* Begin PBXProject section */ 181 | B96C5EA51B15F3670044DAD2 /* Project object */ = { 182 | isa = PBXProject; 183 | attributes = { 184 | LastUpgradeCheck = 0630; 185 | TargetAttributes = { 186 | B96C5EAC1B15F3670044DAD2 = { 187 | CreatedOnToolsVersion = 6.3; 188 | }; 189 | B96C5EC11B15F3680044DAD2 = { 190 | CreatedOnToolsVersion = 6.3; 191 | TestTargetID = B96C5EAC1B15F3670044DAD2; 192 | }; 193 | }; 194 | }; 195 | buildConfigurationList = B96C5EA81B15F3670044DAD2 /* Build configuration list for PBXProject "HowColor" */; 196 | compatibilityVersion = "Xcode 3.2"; 197 | developmentRegion = English; 198 | hasScannedForEncodings = 0; 199 | knownRegions = ( 200 | en, 201 | Base, 202 | ); 203 | mainGroup = B96C5EA41B15F3670044DAD2; 204 | productRefGroup = B96C5EAE1B15F3670044DAD2 /* Products */; 205 | projectDirPath = ""; 206 | projectRoot = ""; 207 | targets = ( 208 | B96C5EAC1B15F3670044DAD2 /* HowColor */, 209 | B96C5EC11B15F3680044DAD2 /* HowColorTests */, 210 | ); 211 | }; 212 | /* End PBXProject section */ 213 | 214 | /* Begin PBXResourcesBuildPhase section */ 215 | B96C5EAB1B15F3670044DAD2 /* Resources */ = { 216 | isa = PBXResourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | B96C5EB81B15F3680044DAD2 /* Main.storyboard in Resources */, 220 | B96C5EBD1B15F3680044DAD2 /* LaunchScreen.xib in Resources */, 221 | B96C5EBA1B15F3680044DAD2 /* Images.xcassets in Resources */, 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | B96C5EC01B15F3680044DAD2 /* Resources */ = { 226 | isa = PBXResourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXResourcesBuildPhase section */ 233 | 234 | /* Begin PBXSourcesBuildPhase section */ 235 | B96C5EA91B15F3670044DAD2 /* Sources */ = { 236 | isa = PBXSourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | B96C5EDA1B15FAA10044DAD2 /* GameViewController.swift in Sources */, 240 | B96C5ED81B15FA830044DAD2 /* ViewController.swift in Sources */, 241 | B96C5EB31B15F3680044DAD2 /* AppDelegate.swift in Sources */, 242 | B96C5ED41B15F7BC0044DAD2 /* UserDefaults.swift in Sources */, 243 | 0D8E730D1B799F9500865BD5 /* Device.swift in Sources */, 244 | ); 245 | runOnlyForDeploymentPostprocessing = 0; 246 | }; 247 | B96C5EBE1B15F3680044DAD2 /* Sources */ = { 248 | isa = PBXSourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | B96C5EC91B15F3680044DAD2 /* HowColorTests.swift in Sources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXSourcesBuildPhase section */ 256 | 257 | /* Begin PBXTargetDependency section */ 258 | B96C5EC41B15F3680044DAD2 /* PBXTargetDependency */ = { 259 | isa = PBXTargetDependency; 260 | target = B96C5EAC1B15F3670044DAD2 /* HowColor */; 261 | targetProxy = B96C5EC31B15F3680044DAD2 /* PBXContainerItemProxy */; 262 | }; 263 | /* End PBXTargetDependency section */ 264 | 265 | /* Begin PBXVariantGroup section */ 266 | B96C5EB61B15F3680044DAD2 /* Main.storyboard */ = { 267 | isa = PBXVariantGroup; 268 | children = ( 269 | B96C5EB71B15F3680044DAD2 /* Base */, 270 | ); 271 | name = Main.storyboard; 272 | sourceTree = ""; 273 | }; 274 | B96C5EBB1B15F3680044DAD2 /* LaunchScreen.xib */ = { 275 | isa = PBXVariantGroup; 276 | children = ( 277 | B96C5EBC1B15F3680044DAD2 /* Base */, 278 | ); 279 | name = LaunchScreen.xib; 280 | sourceTree = ""; 281 | }; 282 | /* End PBXVariantGroup section */ 283 | 284 | /* Begin XCBuildConfiguration section */ 285 | B96C5ECA1B15F3680044DAD2 /* Debug */ = { 286 | isa = XCBuildConfiguration; 287 | buildSettings = { 288 | ALWAYS_SEARCH_USER_PATHS = NO; 289 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 290 | CLANG_CXX_LIBRARY = "libc++"; 291 | CLANG_ENABLE_MODULES = YES; 292 | CLANG_ENABLE_OBJC_ARC = YES; 293 | CLANG_WARN_BOOL_CONVERSION = YES; 294 | CLANG_WARN_CONSTANT_CONVERSION = YES; 295 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 296 | CLANG_WARN_EMPTY_BODY = YES; 297 | CLANG_WARN_ENUM_CONVERSION = YES; 298 | CLANG_WARN_INT_CONVERSION = YES; 299 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 300 | CLANG_WARN_UNREACHABLE_CODE = YES; 301 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 302 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 303 | COPY_PHASE_STRIP = NO; 304 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 305 | ENABLE_STRICT_OBJC_MSGSEND = YES; 306 | GCC_C_LANGUAGE_STANDARD = gnu99; 307 | GCC_DYNAMIC_NO_PIC = NO; 308 | GCC_NO_COMMON_BLOCKS = YES; 309 | GCC_OPTIMIZATION_LEVEL = 0; 310 | GCC_PREPROCESSOR_DEFINITIONS = ( 311 | "DEBUG=1", 312 | "$(inherited)", 313 | ); 314 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 315 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 316 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 317 | GCC_WARN_UNDECLARED_SELECTOR = YES; 318 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 319 | GCC_WARN_UNUSED_FUNCTION = YES; 320 | GCC_WARN_UNUSED_VARIABLE = YES; 321 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 322 | MTL_ENABLE_DEBUG_INFO = YES; 323 | ONLY_ACTIVE_ARCH = YES; 324 | SDKROOT = iphoneos; 325 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 326 | }; 327 | name = Debug; 328 | }; 329 | B96C5ECB1B15F3680044DAD2 /* Release */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ALWAYS_SEARCH_USER_PATHS = NO; 333 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 334 | CLANG_CXX_LIBRARY = "libc++"; 335 | CLANG_ENABLE_MODULES = YES; 336 | CLANG_ENABLE_OBJC_ARC = YES; 337 | CLANG_WARN_BOOL_CONVERSION = YES; 338 | CLANG_WARN_CONSTANT_CONVERSION = YES; 339 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 340 | CLANG_WARN_EMPTY_BODY = YES; 341 | CLANG_WARN_ENUM_CONVERSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 344 | CLANG_WARN_UNREACHABLE_CODE = YES; 345 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 346 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 347 | COPY_PHASE_STRIP = NO; 348 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 349 | ENABLE_NS_ASSERTIONS = NO; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | GCC_C_LANGUAGE_STANDARD = gnu99; 352 | GCC_NO_COMMON_BLOCKS = YES; 353 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 354 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 355 | GCC_WARN_UNDECLARED_SELECTOR = YES; 356 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 357 | GCC_WARN_UNUSED_FUNCTION = YES; 358 | GCC_WARN_UNUSED_VARIABLE = YES; 359 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 360 | MTL_ENABLE_DEBUG_INFO = NO; 361 | SDKROOT = iphoneos; 362 | VALIDATE_PRODUCT = YES; 363 | }; 364 | name = Release; 365 | }; 366 | B96C5ECD1B15F3680044DAD2 /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 370 | INFOPLIST_FILE = HowColor/Info.plist; 371 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 372 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | }; 375 | name = Debug; 376 | }; 377 | B96C5ECE1B15F3680044DAD2 /* Release */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 381 | INFOPLIST_FILE = HowColor/Info.plist; 382 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 384 | PRODUCT_NAME = "$(TARGET_NAME)"; 385 | }; 386 | name = Release; 387 | }; 388 | B96C5ED01B15F3680044DAD2 /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | BUNDLE_LOADER = "$(TEST_HOST)"; 392 | FRAMEWORK_SEARCH_PATHS = ( 393 | "$(SDKROOT)/Developer/Library/Frameworks", 394 | "$(inherited)", 395 | ); 396 | GCC_PREPROCESSOR_DEFINITIONS = ( 397 | "DEBUG=1", 398 | "$(inherited)", 399 | ); 400 | INFOPLIST_FILE = HowColorTests/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HowColor.app/HowColor"; 404 | }; 405 | name = Debug; 406 | }; 407 | B96C5ED11B15F3680044DAD2 /* Release */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | BUNDLE_LOADER = "$(TEST_HOST)"; 411 | FRAMEWORK_SEARCH_PATHS = ( 412 | "$(SDKROOT)/Developer/Library/Frameworks", 413 | "$(inherited)", 414 | ); 415 | INFOPLIST_FILE = HowColorTests/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 417 | PRODUCT_NAME = "$(TARGET_NAME)"; 418 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HowColor.app/HowColor"; 419 | }; 420 | name = Release; 421 | }; 422 | /* End XCBuildConfiguration section */ 423 | 424 | /* Begin XCConfigurationList section */ 425 | B96C5EA81B15F3670044DAD2 /* Build configuration list for PBXProject "HowColor" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | B96C5ECA1B15F3680044DAD2 /* Debug */, 429 | B96C5ECB1B15F3680044DAD2 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | B96C5ECC1B15F3680044DAD2 /* Build configuration list for PBXNativeTarget "HowColor" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | B96C5ECD1B15F3680044DAD2 /* Debug */, 438 | B96C5ECE1B15F3680044DAD2 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | B96C5ECF1B15F3680044DAD2 /* Build configuration list for PBXNativeTarget "HowColorTests" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | B96C5ED01B15F3680044DAD2 /* Debug */, 447 | B96C5ED11B15F3680044DAD2 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | /* End XCConfigurationList section */ 453 | }; 454 | rootObject = B96C5EA51B15F3670044DAD2 /* Project object */; 455 | } 456 | -------------------------------------------------------------------------------- /HowColor.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HowColor/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // HowColor 4 | // 5 | // Created by isaced on 15/5/27. 6 | // 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 | -------------------------------------------------------------------------------- /HowColor/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /HowColor/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 47 | 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 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 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 | -------------------------------------------------------------------------------- /HowColor/Controllers/GameViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameViewController.swift 3 | // HowColor 4 | // 5 | // Created by isaced on 15/5/27. 6 | // 7 | // 8 | 9 | import UIKit 10 | 11 | class GameViewController: UIViewController , UICollectionViewDataSource , UICollectionViewDelegateFlowLayout { 12 | 13 | /// 分数标签 14 | @IBOutlet var scoreLabel: UILabel! 15 | 16 | /// 色块墙 17 | @IBOutlet var tileCollectionView: UICollectionView! 18 | 19 | /// 倒计时显示 20 | @IBOutlet var timeButton: UIButton! 21 | 22 | // --- 23 | 24 | /// 当前级别 25 | var level : Int = 0 26 | 27 | /// 倒计时秒数 28 | var countdown : Int = 60 29 | 30 | /// 计时器 31 | var timer : NSTimer! 32 | 33 | /// 块宽度 34 | var tileWidht : CGFloat = 0 35 | 36 | /// 块数量 37 | var tileCount : Int = 0 38 | 39 | /// 颜色 40 | var colorA : UIColor! 41 | var colorB : UIColor! 42 | 43 | /// 随机颜色的位置 44 | var ranmodColorIndex : Int = 0 45 | 46 | // MARK: - 47 | 48 | override func viewDidLoad() { 49 | super.viewDidLoad() 50 | 51 | // 调整 UICollectionView 样式 52 | tileCollectionView.layer.cornerRadius = 8.0 53 | tileCollectionView.contentInset = UIEdgeInsetsMake(5, 5, 5, 5) 54 | 55 | // 重置计时器 56 | refreshTimeLabel() 57 | 58 | // 计时开始 59 | timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("increaseTimerCount"), userInfo: nil, repeats: true) 60 | 61 | // 根据不同屏幕决定方块数量和大小 62 | if Device.IS_3_5_INCHES() { 63 | tileWidht = 56.0 64 | tileCount = 20 65 | }else if Device.IS_4_INCHES() { 66 | tileWidht = 60.0 67 | tileCount = 24 68 | }else if Device.IS_4_7_INCHES() { 69 | tileWidht = 63.0 70 | tileCount = 28 71 | }else if Device.IS_5_5_INCHES() { 72 | tileWidht = 63.0 73 | tileCount = 40 74 | } 75 | 76 | // 生成颜色 77 | generateColorForLevel(level) 78 | 79 | tileCollectionView.reloadData() 80 | } 81 | 82 | override func didReceiveMemoryWarning() { 83 | super.didReceiveMemoryWarning() 84 | // Dispose of any resources that can be recreated. 85 | } 86 | 87 | // MARK: - 88 | 89 | func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 90 | return tileCount 91 | } 92 | 93 | func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { 94 | return CGSize(width: tileWidht, height: tileWidht) 95 | } 96 | 97 | func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 98 | var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! UICollectionViewCell 99 | 100 | if indexPath.row == self.ranmodColorIndex { 101 | cell.backgroundColor = colorB; 102 | }else{ 103 | cell.backgroundColor = colorA; 104 | } 105 | 106 | return cell 107 | } 108 | 109 | func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { 110 | if indexPath.row == self.ranmodColorIndex { 111 | 112 | level = level + 1 113 | 114 | refreshScoreLabel() 115 | 116 | generateColorForLevel(level); 117 | 118 | // reload CollectionView (使用 reloadSections 会有个默认渐显动画) 119 | tileCollectionView.reloadSections(NSIndexSet(index: 0)) 120 | } 121 | } 122 | 123 | // MARK: - 124 | 125 | @IBAction func goBackAction(sender: UIBarButtonItem) { 126 | 127 | // Timer invalidate 128 | if timer.valid { 129 | timer.invalidate() 130 | } 131 | 132 | // Dismiss 133 | self.dismissViewControllerAnimated(true, completion: nil) 134 | } 135 | 136 | /** 137 | 刷新分数标签 138 | */ 139 | func refreshScoreLabel() { 140 | scoreLabel.text = "\(level)" 141 | } 142 | 143 | /** 144 | 刷新倒计时标签 145 | */ 146 | func refreshTimeLabel() { 147 | timeButton.setTitle("\(countdown)", forState: .Normal) 148 | } 149 | 150 | /** 151 | 计时循环 152 | */ 153 | func increaseTimerCount() { 154 | countdown = countdown - 1 155 | 156 | refreshTimeLabel() 157 | 158 | // Time Over 159 | if self.countdown == 0 { 160 | timer.invalidate() 161 | timerOver() 162 | } 163 | } 164 | 165 | /** 166 | 时间到 167 | */ 168 | func timerOver() { 169 | let alert = UIAlertController(title: "Game Over", message: nil, preferredStyle: .Alert) 170 | self.presentViewController(alert, animated: true, completion: nil) 171 | 172 | // Save Score 173 | UserDefaults.saveBestScore(level) 174 | 175 | let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(2 * Double(NSEC_PER_SEC))) 176 | dispatch_after(delayTime, dispatch_get_main_queue()) { 177 | alert.dismissViewControllerAnimated(true, completion: nil) 178 | self.dismissViewControllerAnimated(true, completion: nil) 179 | } 180 | } 181 | 182 | /** 183 | 根据游戏等级生成颜色 184 | */ 185 | func generateColorForLevel(level:Int) { 186 | let r = CGFloat(arc4random() % 255) 187 | let g = CGFloat(arc4random() % 255) 188 | let b = CGFloat(arc4random() % 255) 189 | 190 | colorA = UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1) 191 | 192 | // 从基数 0.2 开始递增,增量为 0.03 * Level 193 | let alpha = 0.2 + (0.03 * CGFloat(level)); 194 | 195 | colorB = colorA.colorWithAlphaComponent(alpha) 196 | 197 | ranmodColorIndex = Int(arc4random()) % tileCount; 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /HowColor/Controllers/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // HowColor 4 | // 5 | // Created by isaced on 15/5/27. 6 | // 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet var bestScoreLabel: UILabel! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | } 18 | 19 | override func viewWillAppear(animated: Bool) { 20 | bestScoreLabel.text = "Best : \(UserDefaults.bestScore())" 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /HowColor/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 | } -------------------------------------------------------------------------------- /HowColor/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.isaced.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.2 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 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /HowColor/Tools/Device.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Device.swift 3 | // imHome 4 | // 5 | // Created by Kevin Xu on 2/9/15. Updated on 6/20/15. 6 | // Copyright (c) 2015 Alpha Labs, Inc. All rights reserved. 7 | // 8 | import Foundation 9 | import UIKit 10 | 11 | // MARK: - Device Structure 12 | struct Device { 13 | // MARK: - Singletons 14 | static var TheCurrentDevice: UIDevice { 15 | struct Singleton { 16 | static let device = UIDevice.currentDevice() 17 | } 18 | return Singleton.device 19 | } 20 | static var TheCurrentDeviceVersion: Float { 21 | struct Singleton { 22 | 23 | static let version = (UIDevice.currentDevice().systemVersion as NSString).floatValue 24 | } 25 | return Singleton.version 26 | } 27 | static var TheCurrentDeviceHeight: CGFloat { 28 | struct Singleton { 29 | static let height = UIScreen.mainScreen().bounds.size.height 30 | } 31 | return Singleton.height 32 | } 33 | // MARK: - Device Idiom Checks 34 | static var PHONE_OR_PAD: String { 35 | if isPhone() { 36 | return "iPhone" 37 | } else if isPad() { 38 | return "iPad" 39 | } 40 | return "Not iPhone nor iPad" 41 | } 42 | static var DEBUG_OR_RELEASE: String { 43 | #if DEBUG 44 | return "Debug" 45 | #else 46 | return "Release" 47 | #endif 48 | } 49 | static var SIMULATOR_OR_DEVICE: String { 50 | #if (arch(i386) || arch(x86_64)) && os(iOS) 51 | return "Simulator" 52 | #else 53 | return "Device" 54 | #endif 55 | } 56 | // static var CURRENT_DEVICE: String { 57 | // return GBDeviceInfo.deviceInfo().modelString 58 | // } 59 | static func isPhone() -> Bool { 60 | return TheCurrentDevice.userInterfaceIdiom == .Phone 61 | } 62 | static func isPad() -> Bool { 63 | return TheCurrentDevice.userInterfaceIdiom == .Pad 64 | } 65 | static func isDebug() -> Bool { 66 | return DEBUG_OR_RELEASE == "Debug" 67 | } 68 | static func isRelease() -> Bool { 69 | return DEBUG_OR_RELEASE == "Release" 70 | } 71 | static func isSimulator() -> Bool { 72 | return SIMULATOR_OR_DEVICE == "Simulator" 73 | } 74 | static func isDevice() -> Bool { 75 | return SIMULATOR_OR_DEVICE == "Device" 76 | } 77 | // MARK: - Device Version Checks 78 | enum Versions: Float { 79 | case Five = 5.0 80 | case Six = 6.0 81 | case Seven = 7.0 82 | case Eight = 8.0 83 | case Nine = 9.0 84 | } 85 | static func isVersion(version: Versions) -> Bool { 86 | return TheCurrentDeviceVersion >= version.rawValue && TheCurrentDeviceVersion < (version.rawValue + 1.0) 87 | } 88 | static func isVersionOrLater(version: Versions) -> Bool { 89 | return TheCurrentDeviceVersion >= version.rawValue 90 | } 91 | static func isVersionOrEarlier(version: Versions) -> Bool { 92 | return TheCurrentDeviceVersion < (version.rawValue + 1.0) 93 | } 94 | static var CURRENT_VERSION: String { 95 | return "\(TheCurrentDeviceVersion)" 96 | } 97 | // MARK: iOS 5 Checks 98 | static func IS_OS_5() -> Bool { 99 | return isVersion(.Five) 100 | } 101 | static func IS_OS_5_OR_LATER() -> Bool { 102 | return isVersionOrLater(.Five) 103 | } 104 | static func IS_OS_5_OR_EARLIER() -> Bool { 105 | return isVersionOrEarlier(.Five) 106 | } 107 | // MARK: iOS 6 Checks 108 | static func IS_OS_6() -> Bool { 109 | return isVersion(.Six) 110 | } 111 | static func IS_OS_6_OR_LATER() -> Bool { 112 | return isVersionOrLater(.Six) 113 | } 114 | static func IS_OS_6_OR_EARLIER() -> Bool { 115 | return isVersionOrEarlier(.Six) 116 | } 117 | // MARK: iOS 7 Checks 118 | static func IS_OS_7() -> Bool { 119 | return isVersion(.Seven) 120 | } 121 | static func IS_OS_7_OR_LATER() -> Bool { 122 | return isVersionOrLater(.Seven) 123 | } 124 | static func IS_OS_7_OR_EARLIER() -> Bool { 125 | return isVersionOrEarlier(.Seven) 126 | } 127 | // MARK: iOS 8 Checks 128 | static func IS_OS_8() -> Bool { 129 | return isVersion(.Eight) 130 | } 131 | static func IS_OS_8_OR_LATER() -> Bool { 132 | return isVersionOrLater(.Eight) 133 | } 134 | static func IS_OS_8_OR_EARLIER() -> Bool { 135 | return isVersionOrEarlier(.Eight) 136 | } 137 | // MARK: iOS 9 Checks 138 | static func IS_OS_9() -> Bool { 139 | return isVersion(.Nine) 140 | } 141 | static func IS_OS_9_OR_LATER() -> Bool { 142 | return isVersionOrLater(.Nine) 143 | } 144 | static func IS_OS_9_OR_EARLIER() -> Bool { 145 | return isVersionOrEarlier(.Nine) 146 | } 147 | // MARK: - Device Size Checks 148 | enum Heights: CGFloat { 149 | case Inches_3_5 = 480 150 | case Inches_4 = 568 151 | case Inches_4_7 = 667 152 | case Inches_5_5 = 736 153 | } 154 | static func isSize(height: Heights) -> Bool { 155 | return TheCurrentDeviceHeight == height.rawValue 156 | } 157 | static func isSizeOrLarger(height: Heights) -> Bool { 158 | return TheCurrentDeviceHeight >= height.rawValue 159 | } 160 | static func isSizeOrSmaller(height: Heights) -> Bool { 161 | return TheCurrentDeviceHeight <= height.rawValue 162 | } 163 | static var CURRENT_SIZE: String { 164 | if IS_3_5_INCHES() { 165 | return "3.5 Inches" 166 | } else if IS_4_INCHES() { 167 | return "4 Inches" 168 | } else if IS_4_7_INCHES() { 169 | return "4.7 Inches" 170 | } else if IS_5_5_INCHES() { 171 | return "5.5 Inches" 172 | } 173 | return "\(TheCurrentDeviceHeight) Points" 174 | } 175 | // MARK: Retina Check 176 | static func IS_RETINA() -> Bool { 177 | return UIScreen.mainScreen().respondsToSelector("scale") 178 | } 179 | // MARK: 3.5 Inch Checks 180 | static func IS_3_5_INCHES() -> Bool { 181 | return isPhone() && isSize(.Inches_3_5) 182 | } 183 | static func IS_3_5_INCHES_OR_LARGER() -> Bool { 184 | return isPhone() && isSizeOrLarger(.Inches_3_5) 185 | } 186 | static func IS_3_5_INCHES_OR_SMALLER() -> Bool { 187 | return isPhone() && isSizeOrSmaller(.Inches_3_5) 188 | } 189 | // MARK: 4 Inch Checks 190 | static func IS_4_INCHES() -> Bool { 191 | return isPhone() && isSize(.Inches_4) 192 | } 193 | static func IS_4_INCHES_OR_LARGER() -> Bool { 194 | return isPhone() && isSizeOrLarger(.Inches_4) 195 | } 196 | static func IS_4_INCHES_OR_SMALLER() -> Bool { 197 | return isPhone() && isSizeOrSmaller(.Inches_4) 198 | } 199 | // MARK: 4.7 Inch Checks 200 | static func IS_4_7_INCHES() -> Bool { 201 | return isPhone() && isSize(.Inches_4_7) 202 | } 203 | static func IS_4_7_INCHES_OR_LARGER() -> Bool { 204 | return isPhone() && isSizeOrLarger(.Inches_4_7) 205 | } 206 | static func IS_4_7_INCHES_OR_SMALLER() -> Bool { 207 | return isPhone() && isSizeOrLarger(.Inches_4_7) 208 | } 209 | // MARK: 5.5 Inch Checks 210 | static func IS_5_5_INCHES() -> Bool { 211 | return isPhone() && isSize(.Inches_5_5) 212 | } 213 | static func IS_5_5_INCHES_OR_LARGER() -> Bool { 214 | return isPhone() && isSizeOrLarger(.Inches_5_5) 215 | } 216 | static func IS_5_5_INCHES_OR_SMALLER() -> Bool { 217 | return isPhone() && isSizeOrLarger(.Inches_5_5) 218 | } 219 | // MARK: - International Checks 220 | static var CURRENT_REGION: String { 221 | return NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String 222 | } 223 | } -------------------------------------------------------------------------------- /HowColor/Tools/UserDefaults.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UserDefaults.swift 3 | // HowColor 4 | // 5 | // Created by isaced on 15/5/27. 6 | // 7 | // 8 | 9 | import UIKit 10 | 11 | class UserDefaults: NSObject { 12 | 13 | static let BestScoreKey = "BestScore" 14 | 15 | /** 16 | 保存最高分 17 | */ 18 | static func saveBestScore(bestScore : Int){ 19 | var userdefaults = NSUserDefaults.standardUserDefaults() 20 | var oldBestScore = userdefaults.integerForKey(BestScoreKey) 21 | 22 | // 比以前的分数大才写入 23 | if bestScore > oldBestScore { 24 | userdefaults.setInteger(bestScore, forKey: BestScoreKey) 25 | userdefaults.synchronize() 26 | } 27 | } 28 | 29 | /** 30 | 读取最高分 31 | */ 32 | static func bestScore() -> Int { 33 | var bestScore = NSUserDefaults.standardUserDefaults().integerForKey(BestScoreKey) 34 | return bestScore 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /HowColorTests/HowColorTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HowColorTests.swift 3 | // HowColorTests 4 | // 5 | // Created by isaced on 15/5/27. 6 | // 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class HowColorTests: 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 | -------------------------------------------------------------------------------- /HowColorTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.isaced.$(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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 isaced 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HowColor 2 | A small game, written in Swift. Find out the different color and click! 3 | 4 | [Download on the App Store](https://itunes.apple.com/en/app/you-duo-se/id905939990?mt=8) 5 | 6 | ![Screen shots](http://a1.mzstatic.com/us/r30/Purple3/v4/43/d1/70/43d170a8-207b-3adc-e984-ea29ee78379b/screen568x568.jpeg) 7 | ![Screen shots](http://a2.mzstatic.com/us/r30/Purple5/v4/0c/4d/cb/0c4dcbef-7ffc-730a-fc01-11eb2af541f1/screen568x568.jpeg) 8 | --------------------------------------------------------------------------------