├── .gitignore ├── .swift-version ├── .travis.yml ├── Images └── demo.jpg ├── LICENSE ├── Package.swift ├── PickColor.podspec ├── PickColor.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── PickColor.xcscheme ├── PickColor ├── Info.plist ├── PickColor.h └── PickColor.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.2 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8 3 | script: 4 | - xcodebuild -scheme 'PickColor' -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO test | xcpretty -c 5 | -------------------------------------------------------------------------------- /Images/demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/younatics/PickColor/0ca57f6aea13b01d0f58023e615e0957d5b10d1e/Images/demo.jpg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Seungyoun Yi 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 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | import PackageDescription 2 | 3 | let package = Package( 4 | name: "PickColor" 5 | ) 6 | -------------------------------------------------------------------------------- /PickColor.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint YNDropDownMenu.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'PickColor' 11 | s.version = '0.4.0' 12 | s.summary = 'Pick color in image!' 13 | 14 | s.description = <<-DESC 15 | Magic will be happened when you use PickColor! 16 | DESC 17 | 18 | s.homepage = 'https://github.com/younatics/PickColor' 19 | s.license = { :type => 'MIT', :file => 'LICENSE' } 20 | s.author = { "Seungyoun Yi" => "younatics@gmail.com" } 21 | 22 | s.source = { :git => 'https://github.com/younatics/PickColor.git', :tag => s.version.to_s } 23 | s.source_files = 'PickColor/*.swift' 24 | 25 | s.ios.deployment_target = '9.0' 26 | 27 | # s.public_header_files = 'Pod/Classes/**/*.h' 28 | s.frameworks = 'UIKit' 29 | s.requires_arc = true 30 | end 31 | -------------------------------------------------------------------------------- /PickColor.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1921361A1EC8AEFE00647108 /* PickColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 192136181EC8AEFE00647108 /* PickColor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 192136211EC8AF1200647108 /* PickColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192136201EC8AF1200647108 /* PickColor.swift */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXFileReference section */ 15 | 192136151EC8AEFE00647108 /* PickColor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PickColor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 16 | 192136181EC8AEFE00647108 /* PickColor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PickColor.h; sourceTree = ""; }; 17 | 192136191EC8AEFE00647108 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 18 | 192136201EC8AF1200647108 /* PickColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickColor.swift; sourceTree = ""; }; 19 | /* End PBXFileReference section */ 20 | 21 | /* Begin PBXFrameworksBuildPhase section */ 22 | 192136111EC8AEFE00647108 /* Frameworks */ = { 23 | isa = PBXFrameworksBuildPhase; 24 | buildActionMask = 2147483647; 25 | files = ( 26 | ); 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXFrameworksBuildPhase section */ 30 | 31 | /* Begin PBXGroup section */ 32 | 1921360B1EC8AEFE00647108 = { 33 | isa = PBXGroup; 34 | children = ( 35 | 192136171EC8AEFE00647108 /* PickColor */, 36 | 192136161EC8AEFE00647108 /* Products */, 37 | ); 38 | sourceTree = ""; 39 | }; 40 | 192136161EC8AEFE00647108 /* Products */ = { 41 | isa = PBXGroup; 42 | children = ( 43 | 192136151EC8AEFE00647108 /* PickColor.framework */, 44 | ); 45 | name = Products; 46 | sourceTree = ""; 47 | }; 48 | 192136171EC8AEFE00647108 /* PickColor */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 192136181EC8AEFE00647108 /* PickColor.h */, 52 | 192136191EC8AEFE00647108 /* Info.plist */, 53 | 192136201EC8AF1200647108 /* PickColor.swift */, 54 | ); 55 | path = PickColor; 56 | sourceTree = ""; 57 | }; 58 | /* End PBXGroup section */ 59 | 60 | /* Begin PBXHeadersBuildPhase section */ 61 | 192136121EC8AEFE00647108 /* Headers */ = { 62 | isa = PBXHeadersBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | 1921361A1EC8AEFE00647108 /* PickColor.h in Headers */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXHeadersBuildPhase section */ 70 | 71 | /* Begin PBXNativeTarget section */ 72 | 192136141EC8AEFE00647108 /* PickColor */ = { 73 | isa = PBXNativeTarget; 74 | buildConfigurationList = 1921361D1EC8AEFE00647108 /* Build configuration list for PBXNativeTarget "PickColor" */; 75 | buildPhases = ( 76 | 192136101EC8AEFE00647108 /* Sources */, 77 | 192136111EC8AEFE00647108 /* Frameworks */, 78 | 192136121EC8AEFE00647108 /* Headers */, 79 | 192136131EC8AEFE00647108 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = PickColor; 86 | productName = PickColor; 87 | productReference = 192136151EC8AEFE00647108 /* PickColor.framework */; 88 | productType = "com.apple.product-type.framework"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 1921360C1EC8AEFE00647108 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastUpgradeCheck = 1010; 97 | ORGANIZATIONNAME = SeungyounYi; 98 | TargetAttributes = { 99 | 192136141EC8AEFE00647108 = { 100 | CreatedOnToolsVersion = 8.3.2; 101 | DevelopmentTeam = 4G7K3CN2JU; 102 | LastSwiftMigration = 0830; 103 | ProvisioningStyle = Automatic; 104 | }; 105 | }; 106 | }; 107 | buildConfigurationList = 1921360F1EC8AEFE00647108 /* Build configuration list for PBXProject "PickColor" */; 108 | compatibilityVersion = "Xcode 3.2"; 109 | developmentRegion = English; 110 | hasScannedForEncodings = 0; 111 | knownRegions = ( 112 | en, 113 | ); 114 | mainGroup = 1921360B1EC8AEFE00647108; 115 | productRefGroup = 192136161EC8AEFE00647108 /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | 192136141EC8AEFE00647108 /* PickColor */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | 192136131EC8AEFE00647108 /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXResourcesBuildPhase section */ 133 | 134 | /* Begin PBXSourcesBuildPhase section */ 135 | 192136101EC8AEFE00647108 /* Sources */ = { 136 | isa = PBXSourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 192136211EC8AF1200647108 /* PickColor.swift in Sources */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXSourcesBuildPhase section */ 144 | 145 | /* Begin XCBuildConfiguration section */ 146 | 1921361B1EC8AEFE00647108 /* Debug */ = { 147 | isa = XCBuildConfiguration; 148 | buildSettings = { 149 | ALWAYS_SEARCH_USER_PATHS = NO; 150 | CLANG_ANALYZER_NONNULL = YES; 151 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 152 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 153 | CLANG_CXX_LIBRARY = "libc++"; 154 | CLANG_ENABLE_MODULES = YES; 155 | CLANG_ENABLE_OBJC_ARC = YES; 156 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 157 | CLANG_WARN_BOOL_CONVERSION = YES; 158 | CLANG_WARN_COMMA = YES; 159 | CLANG_WARN_CONSTANT_CONVERSION = YES; 160 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 161 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 162 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 163 | CLANG_WARN_EMPTY_BODY = YES; 164 | CLANG_WARN_ENUM_CONVERSION = YES; 165 | CLANG_WARN_INFINITE_RECURSION = YES; 166 | CLANG_WARN_INT_CONVERSION = YES; 167 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 168 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 169 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 170 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 171 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 172 | CLANG_WARN_STRICT_PROTOTYPES = YES; 173 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 174 | CLANG_WARN_UNREACHABLE_CODE = YES; 175 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 176 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 177 | COPY_PHASE_STRIP = NO; 178 | CURRENT_PROJECT_VERSION = 1; 179 | DEBUG_INFORMATION_FORMAT = dwarf; 180 | ENABLE_STRICT_OBJC_MSGSEND = YES; 181 | ENABLE_TESTABILITY = YES; 182 | GCC_C_LANGUAGE_STANDARD = gnu99; 183 | GCC_DYNAMIC_NO_PIC = NO; 184 | GCC_NO_COMMON_BLOCKS = YES; 185 | GCC_OPTIMIZATION_LEVEL = 0; 186 | GCC_PREPROCESSOR_DEFINITIONS = ( 187 | "DEBUG=1", 188 | "$(inherited)", 189 | ); 190 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 191 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 192 | GCC_WARN_UNDECLARED_SELECTOR = YES; 193 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 194 | GCC_WARN_UNUSED_FUNCTION = YES; 195 | GCC_WARN_UNUSED_VARIABLE = YES; 196 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 197 | MTL_ENABLE_DEBUG_INFO = YES; 198 | ONLY_ACTIVE_ARCH = YES; 199 | SDKROOT = iphoneos; 200 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 201 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 202 | SWIFT_VERSION = 4.2; 203 | TARGETED_DEVICE_FAMILY = "1,2"; 204 | VERSIONING_SYSTEM = "apple-generic"; 205 | VERSION_INFO_PREFIX = ""; 206 | }; 207 | name = Debug; 208 | }; 209 | 1921361C1EC8AEFE00647108 /* Release */ = { 210 | isa = XCBuildConfiguration; 211 | buildSettings = { 212 | ALWAYS_SEARCH_USER_PATHS = NO; 213 | CLANG_ANALYZER_NONNULL = YES; 214 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 215 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 216 | CLANG_CXX_LIBRARY = "libc++"; 217 | CLANG_ENABLE_MODULES = YES; 218 | CLANG_ENABLE_OBJC_ARC = YES; 219 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 220 | CLANG_WARN_BOOL_CONVERSION = YES; 221 | CLANG_WARN_COMMA = YES; 222 | CLANG_WARN_CONSTANT_CONVERSION = YES; 223 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 226 | CLANG_WARN_EMPTY_BODY = YES; 227 | CLANG_WARN_ENUM_CONVERSION = YES; 228 | CLANG_WARN_INFINITE_RECURSION = YES; 229 | CLANG_WARN_INT_CONVERSION = YES; 230 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 231 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 232 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 234 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 235 | CLANG_WARN_STRICT_PROTOTYPES = YES; 236 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 237 | CLANG_WARN_UNREACHABLE_CODE = YES; 238 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 239 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 240 | COPY_PHASE_STRIP = NO; 241 | CURRENT_PROJECT_VERSION = 1; 242 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 243 | ENABLE_NS_ASSERTIONS = NO; 244 | ENABLE_STRICT_OBJC_MSGSEND = YES; 245 | GCC_C_LANGUAGE_STANDARD = gnu99; 246 | GCC_NO_COMMON_BLOCKS = YES; 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 254 | MTL_ENABLE_DEBUG_INFO = NO; 255 | SDKROOT = iphoneos; 256 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 257 | SWIFT_VERSION = 4.2; 258 | TARGETED_DEVICE_FAMILY = "1,2"; 259 | VALIDATE_PRODUCT = YES; 260 | VERSIONING_SYSTEM = "apple-generic"; 261 | VERSION_INFO_PREFIX = ""; 262 | }; 263 | name = Release; 264 | }; 265 | 1921361E1EC8AEFE00647108 /* Debug */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | CLANG_ENABLE_MODULES = YES; 269 | CODE_SIGN_IDENTITY = ""; 270 | DEFINES_MODULE = YES; 271 | DEVELOPMENT_TEAM = 4G7K3CN2JU; 272 | DYLIB_COMPATIBILITY_VERSION = 1; 273 | DYLIB_CURRENT_VERSION = 1; 274 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 275 | INFOPLIST_FILE = PickColor/Info.plist; 276 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 277 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 278 | PRODUCT_BUNDLE_IDENTIFIER = com.seungyounyi.PickColor; 279 | PRODUCT_NAME = "$(TARGET_NAME)"; 280 | SKIP_INSTALL = YES; 281 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 282 | SWIFT_VERSION = 4.2; 283 | }; 284 | name = Debug; 285 | }; 286 | 1921361F1EC8AEFE00647108 /* Release */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | CLANG_ENABLE_MODULES = YES; 290 | CODE_SIGN_IDENTITY = ""; 291 | DEFINES_MODULE = YES; 292 | DEVELOPMENT_TEAM = 4G7K3CN2JU; 293 | DYLIB_COMPATIBILITY_VERSION = 1; 294 | DYLIB_CURRENT_VERSION = 1; 295 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 296 | INFOPLIST_FILE = PickColor/Info.plist; 297 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 298 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 299 | PRODUCT_BUNDLE_IDENTIFIER = com.seungyounyi.PickColor; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | SKIP_INSTALL = YES; 302 | SWIFT_VERSION = 4.2; 303 | }; 304 | name = Release; 305 | }; 306 | /* End XCBuildConfiguration section */ 307 | 308 | /* Begin XCConfigurationList section */ 309 | 1921360F1EC8AEFE00647108 /* Build configuration list for PBXProject "PickColor" */ = { 310 | isa = XCConfigurationList; 311 | buildConfigurations = ( 312 | 1921361B1EC8AEFE00647108 /* Debug */, 313 | 1921361C1EC8AEFE00647108 /* Release */, 314 | ); 315 | defaultConfigurationIsVisible = 0; 316 | defaultConfigurationName = Release; 317 | }; 318 | 1921361D1EC8AEFE00647108 /* Build configuration list for PBXNativeTarget "PickColor" */ = { 319 | isa = XCConfigurationList; 320 | buildConfigurations = ( 321 | 1921361E1EC8AEFE00647108 /* Debug */, 322 | 1921361F1EC8AEFE00647108 /* Release */, 323 | ); 324 | defaultConfigurationIsVisible = 0; 325 | defaultConfigurationName = Release; 326 | }; 327 | /* End XCConfigurationList section */ 328 | }; 329 | rootObject = 1921360C1EC8AEFE00647108 /* Project object */; 330 | } 331 | -------------------------------------------------------------------------------- /PickColor.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PickColor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PickColor.xcodeproj/xcshareddata/xcschemes/PickColor.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 | -------------------------------------------------------------------------------- /PickColor/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /PickColor/PickColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // PickColor.h 3 | // PickColor 4 | // 5 | // Created by YiSeungyoun on 2017. 5. 15.. 6 | // Copyright © 2017년 SeungyounYi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for PickColor. 12 | FOUNDATION_EXPORT double PickColorVersionNumber; 13 | 14 | //! Project version string for PickColor. 15 | FOUNDATION_EXPORT const unsigned char PickColorVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /PickColor/PickColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PickColor.swift 3 | // PickColor 4 | // 5 | // Created by YiSeungyoun on 2017. 5. 15.. 6 | // Copyright © 2017년 SeungyounYi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIImage { 12 | open func pickColor() -> UIColor { 13 | 14 | var bitmap = [UInt8](repeating: 0, count: 4) 15 | 16 | let context = CIContext(options: nil) 17 | let cgImg = context.createCGImage(CoreImage.CIImage(cgImage: self.cgImage!), from: CoreImage.CIImage(cgImage: self.cgImage!).extent) 18 | 19 | let inputImage = CIImage(cgImage: cgImg!) 20 | let extent = inputImage.extent 21 | let inputExtent = CIVector(x: extent.origin.x, y: extent.origin.y, z: extent.size.width, w: extent.size.height) 22 | let filter = CIFilter(name: "CIAreaAverage", parameters: [kCIInputImageKey: inputImage, kCIInputExtentKey: inputExtent])! 23 | let outputImage = filter.outputImage! 24 | let outputExtent = outputImage.extent 25 | assert(outputExtent.size.width == 1 && outputExtent.size.height == 1) 26 | 27 | context.render(outputImage, toBitmap: &bitmap, rowBytes: 4, bounds: CGRect(x: 0, y: 0, width: 1, height: 1), format: CIFormat.RGBA8, colorSpace: CGColorSpaceCreateDeviceRGB()) 28 | 29 | let result = UIColor(red: CGFloat(bitmap[0]) / 255.0, green: CGFloat(bitmap[1]) / 255.0, blue: CGFloat(bitmap[2]) / 255.0, alpha: CGFloat(bitmap[3]) / 255.0) 30 | return result 31 | } 32 | 33 | open func pickColorHexstring() -> String { 34 | let color = self.pickColor() 35 | let hexString = String(format: "%02X%02X%02X", 36 | Int((color.cgColor.components?[0])! * 255.0), 37 | Int((color.cgColor.components?[1])! * 255.0), 38 | Int((color.cgColor.components?[2])! * 255.0)) 39 | return hexString 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PickColor 2 | [![Version](https://img.shields.io/cocoapods/v/PickColor.svg?style=flat)](http://cocoapods.org/pods/PickColor) 3 | [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/younatics/PickColor/blob/master/LICENSE) 5 | [![Build Status](https://travis-ci.org/younatics/PickColor.svg?branch=master)](https://travis-ci.org/younatics/PickColor) 6 | [![Platform](https://img.shields.io/cocoapods/p/PickColor.svg?style=flat)](http://cocoapods.org/pods/PickColor) 7 | [![Swift 4.2](https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat)](https://developer.apple.com/swift/) 8 | 9 | ## Intoduction 10 | 📌 Pick color in your image! It will magically return average color in your `UIImage`!. Also, you can get hexstring from `PickColor` 11 | 12 | ![demo](Images/demo.jpg) 13 | 14 | 15 | ## Requirements 16 | 17 | `PickColor` is written in Swift 4.2 Compatible with iOS 9.0+ 18 | 19 | ## Installation 20 | 21 | ### Cocoapods 22 | 23 | PickColor is available through [CocoaPods](http://cocoapods.org). To install 24 | it, simply add the following line to your Podfile: 25 | 26 | ```ruby 27 | pod 'PickColor' 28 | ``` 29 | ### Carthage 30 | ``` 31 | github "younatics/PickColor" 32 | ``` 33 | ## Usage 34 | Get `UIColor` 35 | ```swift 36 | let UIColor = UIImage.pickColor() 37 | ``` 38 | 39 | Get `HexString` 40 | ```swift 41 | let UIColorHexString = UIImage.pickColorHexstring() 42 | ``` 43 | 44 | ## References 45 | #### Please tell me or make pull request if you use this library in your application :) 46 | 47 | ## Author 48 | [younatics](https://twitter.com/younatics) 49 | Twitter 50 | 51 | ## License 52 | PickColor is available under the MIT license. See the LICENSE file for more info. 53 | 54 | 55 | --------------------------------------------------------------------------------