├── DDColorExplorer.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── admin.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── admin.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── DDColorExplorer.xcscheme │ └── xcschememanagement.plist ├── DDColorExplorer ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.swift └── test.png ├── README.md ├── Sources └── DDColorExplorer.swift └── demo.gif /DDColorExplorer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8451445B1C5123E90007CD59 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8451445A1C5123E90007CD59 /* AppDelegate.swift */; }; 11 | 8451445D1C5123E90007CD59 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8451445C1C5123E90007CD59 /* ViewController.swift */; }; 12 | 845144601C5123E90007CD59 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8451445E1C5123E90007CD59 /* Main.storyboard */; }; 13 | 845144621C5123E90007CD59 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 845144611C5123E90007CD59 /* Assets.xcassets */; }; 14 | 845144651C5123E90007CD59 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 845144631C5123E90007CD59 /* LaunchScreen.storyboard */; }; 15 | 8451446F1C512F920007CD59 /* test.png in Resources */ = {isa = PBXBuildFile; fileRef = 8451446E1C512F920007CD59 /* test.png */; }; 16 | 845144731C513EDB0007CD59 /* DDColorExplorer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845144721C513EDB0007CD59 /* DDColorExplorer.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 845144571C5123E90007CD59 /* DDColorExplorer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DDColorExplorer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 8451445A1C5123E90007CD59 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 8451445C1C5123E90007CD59 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 23 | 8451445F1C5123E90007CD59 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 24 | 845144611C5123E90007CD59 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 845144641C5123E90007CD59 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | 845144661C5123E90007CD59 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 8451446E1C512F920007CD59 /* test.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = test.png; sourceTree = ""; }; 28 | 845144721C513EDB0007CD59 /* DDColorExplorer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DDColorExplorer.swift; path = Sources/DDColorExplorer.swift; sourceTree = SOURCE_ROOT; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 845144541C5123E90007CD59 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 8451444E1C5123E90007CD59 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 845144591C5123E90007CD59 /* DDColorExplorer */, 46 | 845144581C5123E90007CD59 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 845144581C5123E90007CD59 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 845144571C5123E90007CD59 /* DDColorExplorer.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 845144591C5123E90007CD59 /* DDColorExplorer */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 845144741C513EE00007CD59 /* Source */, 62 | 8451445A1C5123E90007CD59 /* AppDelegate.swift */, 63 | 8451445C1C5123E90007CD59 /* ViewController.swift */, 64 | 8451446E1C512F920007CD59 /* test.png */, 65 | 8451445E1C5123E90007CD59 /* Main.storyboard */, 66 | 845144611C5123E90007CD59 /* Assets.xcassets */, 67 | 845144631C5123E90007CD59 /* LaunchScreen.storyboard */, 68 | 845144661C5123E90007CD59 /* Info.plist */, 69 | ); 70 | path = DDColorExplorer; 71 | sourceTree = ""; 72 | }; 73 | 845144741C513EE00007CD59 /* Source */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 845144721C513EDB0007CD59 /* DDColorExplorer.swift */, 77 | ); 78 | name = Source; 79 | sourceTree = ""; 80 | }; 81 | /* End PBXGroup section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 845144561C5123E90007CD59 /* DDColorExplorer */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 845144691C5123E90007CD59 /* Build configuration list for PBXNativeTarget "DDColorExplorer" */; 87 | buildPhases = ( 88 | 845144531C5123E90007CD59 /* Sources */, 89 | 845144541C5123E90007CD59 /* Frameworks */, 90 | 845144551C5123E90007CD59 /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = DDColorExplorer; 97 | productName = DDColorExplorer; 98 | productReference = 845144571C5123E90007CD59 /* DDColorExplorer.app */; 99 | productType = "com.apple.product-type.application"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 8451444F1C5123E90007CD59 /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastSwiftUpdateCheck = 0720; 108 | LastUpgradeCheck = 0720; 109 | ORGANIZATIONNAME = "monk-studio"; 110 | TargetAttributes = { 111 | 845144561C5123E90007CD59 = { 112 | CreatedOnToolsVersion = 7.2; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 845144521C5123E90007CD59 /* Build configuration list for PBXProject "DDColorExplorer" */; 117 | compatibilityVersion = "Xcode 3.2"; 118 | developmentRegion = English; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 8451444E1C5123E90007CD59; 125 | productRefGroup = 845144581C5123E90007CD59 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 845144561C5123E90007CD59 /* DDColorExplorer */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 845144551C5123E90007CD59 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 845144651C5123E90007CD59 /* LaunchScreen.storyboard in Resources */, 140 | 845144621C5123E90007CD59 /* Assets.xcassets in Resources */, 141 | 845144601C5123E90007CD59 /* Main.storyboard in Resources */, 142 | 8451446F1C512F920007CD59 /* test.png in Resources */, 143 | ); 144 | runOnlyForDeploymentPostprocessing = 0; 145 | }; 146 | /* End PBXResourcesBuildPhase section */ 147 | 148 | /* Begin PBXSourcesBuildPhase section */ 149 | 845144531C5123E90007CD59 /* Sources */ = { 150 | isa = PBXSourcesBuildPhase; 151 | buildActionMask = 2147483647; 152 | files = ( 153 | 845144731C513EDB0007CD59 /* DDColorExplorer.swift in Sources */, 154 | 8451445D1C5123E90007CD59 /* ViewController.swift in Sources */, 155 | 8451445B1C5123E90007CD59 /* AppDelegate.swift in Sources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXSourcesBuildPhase section */ 160 | 161 | /* Begin PBXVariantGroup section */ 162 | 8451445E1C5123E90007CD59 /* Main.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | 8451445F1C5123E90007CD59 /* Base */, 166 | ); 167 | name = Main.storyboard; 168 | sourceTree = ""; 169 | }; 170 | 845144631C5123E90007CD59 /* LaunchScreen.storyboard */ = { 171 | isa = PBXVariantGroup; 172 | children = ( 173 | 845144641C5123E90007CD59 /* Base */, 174 | ); 175 | name = LaunchScreen.storyboard; 176 | sourceTree = ""; 177 | }; 178 | /* End PBXVariantGroup section */ 179 | 180 | /* Begin XCBuildConfiguration section */ 181 | 845144671C5123E90007CD59 /* Debug */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_MODULES = YES; 188 | CLANG_ENABLE_OBJC_ARC = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_CONSTANT_CONVERSION = YES; 191 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 192 | CLANG_WARN_EMPTY_BODY = YES; 193 | CLANG_WARN_ENUM_CONVERSION = YES; 194 | CLANG_WARN_INT_CONVERSION = YES; 195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 196 | CLANG_WARN_UNREACHABLE_CODE = YES; 197 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 198 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 199 | COPY_PHASE_STRIP = NO; 200 | DEBUG_INFORMATION_FORMAT = dwarf; 201 | ENABLE_STRICT_OBJC_MSGSEND = YES; 202 | ENABLE_TESTABILITY = YES; 203 | GCC_C_LANGUAGE_STANDARD = gnu99; 204 | GCC_DYNAMIC_NO_PIC = NO; 205 | GCC_NO_COMMON_BLOCKS = YES; 206 | GCC_OPTIMIZATION_LEVEL = 0; 207 | GCC_PREPROCESSOR_DEFINITIONS = ( 208 | "DEBUG=1", 209 | "$(inherited)", 210 | ); 211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 213 | GCC_WARN_UNDECLARED_SELECTOR = YES; 214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 215 | GCC_WARN_UNUSED_FUNCTION = YES; 216 | GCC_WARN_UNUSED_VARIABLE = YES; 217 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 218 | MTL_ENABLE_DEBUG_INFO = YES; 219 | ONLY_ACTIVE_ARCH = YES; 220 | SDKROOT = iphoneos; 221 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 222 | }; 223 | name = Debug; 224 | }; 225 | 845144681C5123E90007CD59 /* Release */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | ALWAYS_SEARCH_USER_PATHS = NO; 229 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 230 | CLANG_CXX_LIBRARY = "libc++"; 231 | CLANG_ENABLE_MODULES = YES; 232 | CLANG_ENABLE_OBJC_ARC = YES; 233 | CLANG_WARN_BOOL_CONVERSION = YES; 234 | CLANG_WARN_CONSTANT_CONVERSION = YES; 235 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 236 | CLANG_WARN_EMPTY_BODY = YES; 237 | CLANG_WARN_ENUM_CONVERSION = YES; 238 | CLANG_WARN_INT_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_UNREACHABLE_CODE = YES; 241 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 242 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 243 | COPY_PHASE_STRIP = NO; 244 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 245 | ENABLE_NS_ASSERTIONS = NO; 246 | ENABLE_STRICT_OBJC_MSGSEND = YES; 247 | GCC_C_LANGUAGE_STANDARD = gnu99; 248 | GCC_NO_COMMON_BLOCKS = YES; 249 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 250 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 251 | GCC_WARN_UNDECLARED_SELECTOR = YES; 252 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 253 | GCC_WARN_UNUSED_FUNCTION = YES; 254 | GCC_WARN_UNUSED_VARIABLE = YES; 255 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 256 | MTL_ENABLE_DEBUG_INFO = NO; 257 | SDKROOT = iphoneos; 258 | VALIDATE_PRODUCT = YES; 259 | }; 260 | name = Release; 261 | }; 262 | 8451446A1C5123E90007CD59 /* Debug */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 266 | INFOPLIST_FILE = DDColorExplorer/Info.plist; 267 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 268 | PRODUCT_BUNDLE_IDENTIFIER = "com.monk-studio.DDColorExplorer"; 269 | PRODUCT_NAME = "$(TARGET_NAME)"; 270 | }; 271 | name = Debug; 272 | }; 273 | 8451446B1C5123E90007CD59 /* Release */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 277 | INFOPLIST_FILE = DDColorExplorer/Info.plist; 278 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 279 | PRODUCT_BUNDLE_IDENTIFIER = "com.monk-studio.DDColorExplorer"; 280 | PRODUCT_NAME = "$(TARGET_NAME)"; 281 | }; 282 | name = Release; 283 | }; 284 | /* End XCBuildConfiguration section */ 285 | 286 | /* Begin XCConfigurationList section */ 287 | 845144521C5123E90007CD59 /* Build configuration list for PBXProject "DDColorExplorer" */ = { 288 | isa = XCConfigurationList; 289 | buildConfigurations = ( 290 | 845144671C5123E90007CD59 /* Debug */, 291 | 845144681C5123E90007CD59 /* Release */, 292 | ); 293 | defaultConfigurationIsVisible = 0; 294 | defaultConfigurationName = Release; 295 | }; 296 | 845144691C5123E90007CD59 /* Build configuration list for PBXNativeTarget "DDColorExplorer" */ = { 297 | isa = XCConfigurationList; 298 | buildConfigurations = ( 299 | 8451446A1C5123E90007CD59 /* Debug */, 300 | 8451446B1C5123E90007CD59 /* Release */, 301 | ); 302 | defaultConfigurationIsVisible = 0; 303 | defaultConfigurationName = Release; 304 | }; 305 | /* End XCConfigurationList section */ 306 | }; 307 | rootObject = 8451444F1C5123E90007CD59 /* Project object */; 308 | } 309 | -------------------------------------------------------------------------------- /DDColorExplorer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DDColorExplorer.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/DDColorExplorer/1652ad4dd11aa3060d778816273bc8bbab9be9f4/DDColorExplorer.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DDColorExplorer.xcodeproj/xcuserdata/admin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /DDColorExplorer.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/DDColorExplorer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /DDColorExplorer.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DDColorExplorer.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 845144561C5123E90007CD59 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /DDColorExplorer/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DDColorExplorer 4 | // 5 | // Created by Carrl on 16/1/21. 6 | // Copyright © 2016年 monk-studio. 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 | -------------------------------------------------------------------------------- /DDColorExplorer/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /DDColorExplorer/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DDColorExplorer/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 | -------------------------------------------------------------------------------- /DDColorExplorer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /DDColorExplorer/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DDColorExplorer 4 | // 5 | // Created by Carrl on 16/1/21. 6 | // Copyright © 2016年 monk-studio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | let presentationView = UIView(frame: CGRectMake(0, 20, 50, 50)) 13 | 14 | let labelRed = UILabel(frame: CGRectMake(0, 70, 100, 20)) 15 | let labelGreen = UILabel(frame: CGRectMake(0, 90, 100, 20)) 16 | let labelBlue = UILabel(frame: CGRectMake(0, 110, 100, 20)) 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | let explorerView = DDColorExplorerView(image: UIImage(named: "test.png")) 20 | explorerView.backgroundColor = UIColor.whiteColor() 21 | explorerView.frame = self.view.frame 22 | explorerView.delegate = self 23 | self.view.addSubview(explorerView) 24 | 25 | self.presentationView.layer.zPosition = 100 26 | presentationView.center.x = self.view.center.x 27 | self.view.addSubview(presentationView) 28 | 29 | for member in [labelRed,labelBlue,labelGreen]{ 30 | member.textColor = UIColor.grayColor() 31 | member.center.x = self.view.center.x 32 | member.textAlignment = NSTextAlignment.Center 33 | self.view.addSubview(member) 34 | } 35 | } 36 | 37 | } 38 | extension ViewController: DDColorExplorerViewDelegate{ 39 | func DDColorExplorerDidDetectColor(color: UIColor) { 40 | self.presentationView.backgroundColor = color 41 | self.labelRed.text = "red:\(color.red)" 42 | self.labelGreen.text = "green:\(color.green)" 43 | self.labelBlue.text = "blue:\(color.blue)" 44 | } 45 | } 46 | 47 | extension UIColor{ 48 | 49 | var red: Int{ 50 | return Int(CGColorGetComponents(self.CGColor)[0] * 255.0) 51 | } 52 | 53 | var green: Int{ 54 | return Int(CGColorGetComponents(self.CGColor)[1] * 255.0) 55 | } 56 | 57 | var blue: Int{ 58 | return Int(CGColorGetComponents(self.CGColor)[2] * 255.0) 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /DDColorExplorer/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/DDColorExplorer/1652ad4dd11aa3060d778816273bc8bbab9be9f4/DDColorExplorer/test.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DDColorExplorer 2 | --- 3 | 4 | ### Demo 5 | ![demo](https://raw.githubusercontent.com/wddwycc/DDColorExplorer/master/demo.gif) 6 | 7 | 8 | ### How To Use 9 | 1. Copy the file `DDColorExplorer.swift` into your project. 10 | 11 | 2. Use `DDColorExplorerView` to get the control and `DDColorExplorerViewDelegate` to retrieve color data. 12 | -------------------------------------------------------------------------------- /Sources/DDColorExplorer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DDColorExplorer.swift 3 | // DDColorExplorer 4 | // 5 | // Created by Carrl on 16/1/21. 6 | // Copyright © 2016年 monk-studio. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol DDColorExplorerViewDelegate:class{ 12 | func DDColorExplorerDidDetectColor(color:UIColor) 13 | } 14 | class DDColorExplorerView:UIImageView{ 15 | 16 | private let picker = UIView(frame: CGRectMake(0, 0, 80, 80)) 17 | private let pickerPresentationLayer = CAShapeLayer() 18 | var pickerColor:CGColorRef?{ 19 | get{ 20 | return self.pickerPresentationLayer.strokeColor 21 | } 22 | set(newValue){ 23 | self.pickerPresentationLayer.strokeColor = newValue 24 | } 25 | } 26 | 27 | var context:CGContextRef? 28 | 29 | let pickerDisappearDuration = 0.6 as Double 30 | 31 | 32 | weak var delegate:DDColorExplorerViewDelegate? 33 | 34 | override init(image:UIImage?){ 35 | super.init(image: image) 36 | self.contentMode = UIViewContentMode.ScaleAspectFit 37 | self.activateColorExploration() 38 | if(self.image != nil){ 39 | self.context = self.createARGBBitmapContext(self.image!.CGImage!) 40 | } 41 | 42 | } 43 | 44 | required init?(coder aDecoder: NSCoder) { 45 | fatalError("init(coder:) has not been implemented") 46 | } 47 | private func activateColorExploration(){ 48 | self.userInteractionEnabled = true 49 | let panGesture = UIPanGestureRecognizer(target: self, action: "colorExplorerHandlePan:") 50 | let tapGesture = UITapGestureRecognizer(target: self, action: "colorExplorerHandleTap:") 51 | self.addGestureRecognizer(panGesture) 52 | self.addGestureRecognizer(tapGesture) 53 | 54 | pickerPresentationLayer.frame = self.picker.frame 55 | self.picker.layer.addSublayer(pickerPresentationLayer) 56 | let pickerPath = CGPathCreateMutable() 57 | CGPathAddEllipseInRect(pickerPath, nil, pickerPresentationLayer.frame) 58 | pickerPresentationLayer.path = pickerPath 59 | pickerPresentationLayer.fillColor = UIColor.clearColor().CGColor 60 | pickerPresentationLayer.strokeColor = UIColor.grayColor().CGColor 61 | pickerPresentationLayer.lineWidth = 10 62 | 63 | let centerPointLayer = CAShapeLayer() 64 | let centerPointLayerPath = CGPathCreateMutable() 65 | CGPathAddEllipseInRect(centerPointLayerPath, nil, CGRectMake(0, 0, 4, 4)) 66 | centerPointLayer.path = centerPointLayerPath 67 | centerPointLayer.strokeColor = UIColor.clearColor().CGColor 68 | centerPointLayer.fillColor = UIColor(white: 172.0/255.0, alpha: 1).CGColor 69 | centerPointLayer.frame = CGRectMake(80/2 - 2, 80/2 - 2, 4, 4) 70 | self.picker.layer.addSublayer(centerPointLayer) 71 | 72 | self.picker.alpha = 0 73 | self.addSubview(self.picker) 74 | } 75 | func colorExplorerHandlePan(gesture:UIPanGestureRecognizer){ 76 | let locationInImage = self.covertTouchPositionToImagePixelPosition(gesture.locationInView(self)) 77 | let color = self.getPixelColorAtLocation(locationInImage) 78 | self.pickerColor = color!.CGColor 79 | if(color != nil){ 80 | self.delegate?.DDColorExplorerDidDetectColor(color!) 81 | } 82 | 83 | switch gesture.state{ 84 | case .Began: 85 | self.picker.alpha = 1 86 | self.picker.center = gesture.locationInView(self) 87 | case .Changed: 88 | self.picker.center = gesture.locationInView(self) 89 | 90 | case .Cancelled, .Ended: 91 | UIView.animateWithDuration(self.pickerDisappearDuration, animations: { () -> Void in 92 | self.picker.alpha = 0 93 | }) 94 | default: 95 | break 96 | } 97 | } 98 | func colorExplorerHandleTap(gesture:UITapGestureRecognizer){ 99 | if(gesture.state == .Ended){ 100 | let locationInImage = self.covertTouchPositionToImagePixelPosition(gesture.locationInView(self)) 101 | let color = self.getPixelColorAtLocation(locationInImage) 102 | self.pickerColor = color!.CGColor 103 | if(color != nil){ 104 | self.delegate?.DDColorExplorerDidDetectColor(color!) 105 | } 106 | 107 | 108 | 109 | self.picker.center = gesture.locationInView(self) 110 | self.picker.alpha = 1 111 | UIView.animateWithDuration(self.pickerDisappearDuration, animations: { () -> Void in 112 | self.picker.alpha = 0 113 | }) 114 | } 115 | } 116 | 117 | func covertTouchPositionToImagePixelPosition(touchPosition:CGPoint)->CGPoint?{ 118 | let imageSize = CGSizeMake(CGFloat(CGImageGetWidth(self.image!.CGImage)), CGFloat(CGImageGetHeight(self.image!.CGImage))) 119 | 120 | let explorerViewSize = self.bounds.size 121 | let presentationRatio = (imageSize.width / explorerViewSize.width > imageSize.height / explorerViewSize.width) ? (imageSize.width / explorerViewSize.width) : (imageSize.height / explorerViewSize.height) 122 | let presentationSize = CGSizeMake(imageSize.width / presentationRatio, imageSize.height / presentationRatio) 123 | 124 | 125 | if(touchPosition.x < (explorerViewSize.width - presentationSize.width)/2 || touchPosition.x > (explorerViewSize.width + presentationSize.width)/2){ 126 | return nil 127 | } 128 | if(touchPosition.y < (explorerViewSize.height - presentationSize.height)/2 || touchPosition.y > (explorerViewSize.height + presentationSize.height)/2){ 129 | return nil 130 | } 131 | let leftInset = (explorerViewSize.width - presentationSize.width)/2 132 | let topInset = (explorerViewSize.height - presentationSize.height)/2 133 | let targetPositionInExplorerView = CGPointMake(touchPosition.x - leftInset, touchPosition.y - topInset) 134 | 135 | let positionInImage = CGPointMake(targetPositionInExplorerView.x * presentationRatio, targetPositionInExplorerView.y * presentationRatio) 136 | 137 | return positionInImage 138 | } 139 | 140 | 141 | private func createARGBBitmapContext(inImage: CGImageRef) -> CGContext { 142 | 143 | let pixelsWide = CGImageGetWidth(inImage) 144 | let pixelsHigh = CGImageGetHeight(inImage) 145 | 146 | let bitmapBytesPerRow = Int(pixelsWide) * 4 147 | 148 | let colorSpace = CGColorSpaceCreateDeviceRGB() 149 | 150 | let bitmapData = UnsafeMutablePointer() 151 | let bitmapInfo = CGImageAlphaInfo.PremultipliedFirst.rawValue 152 | 153 | let context = CGBitmapContextCreate(bitmapData, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, bitmapInfo)! 154 | 155 | return context 156 | } 157 | 158 | private func getPixelColorAtLocation(point:CGPoint?)->UIColor? { 159 | if(point == nil){ 160 | return self.backgroundColor 161 | } 162 | let inImage:CGImageRef = self.image!.CGImage! 163 | 164 | let pixelsWide = CGImageGetWidth(inImage) 165 | let pixelsHigh = CGImageGetHeight(inImage) 166 | let rect = CGRect(x:0, y:0, width:Int(pixelsWide), height:Int(pixelsHigh)) 167 | 168 | CGContextClearRect(context, rect) 169 | 170 | CGContextDrawImage(context, rect, inImage) 171 | 172 | let data = CGBitmapContextGetData(context) 173 | let dataType = UnsafePointer(data) 174 | 175 | let offset = 4*((Int(pixelsWide) * Int(point!.y)) + Int(point!.x)) 176 | let alphaValue = dataType[offset] 177 | let redColor = dataType[offset+1] 178 | let greenColor = dataType[offset+2] 179 | let blueColor = dataType[offset+3] 180 | 181 | let redFloat = CGFloat(redColor)/255.0 182 | let greenFloat = CGFloat(greenColor)/255.0 183 | let blueFloat = CGFloat(blueColor)/255.0 184 | let alphaFloat = CGFloat(alphaValue)/255.0 185 | 186 | return UIColor(red: redFloat, green: greenFloat, blue: blueFloat, alpha: alphaFloat) 187 | 188 | // When finished, release the context 189 | // Free image data memory for the context 190 | } 191 | 192 | 193 | 194 | } 195 | 196 | 197 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wddwycc/DDColorExplorer/1652ad4dd11aa3060d778816273bc8bbab9be9f4/demo.gif --------------------------------------------------------------------------------