├── LICENSE.md ├── README.md ├── Screenshots ├── Image01.png ├── Image01_Thumb.png ├── Image02.png └── Image02_Thumb.png ├── iOS_Swift_ColorPicker.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── alex_ling.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── alex_ling.xcuserdatad │ └── xcschemes │ │ ├── iOS_Swift_ColorPicker.xcscheme │ │ ├── iOS_Swift_ColorPicker_Programmatically.xcscheme │ │ ├── iOS_Swift_ColorPicker_Storyboard.xcscheme │ │ └── xcschememanagement.plist │ └── christianzimmermann.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── iOS_Swift_ColorPicker ├── Info.plist ├── SwiftColorPickerViewController.swift └── iOS_Swift_ColorPicker.h ├── iOS_Swift_ColorPicker_Programmatically ├── AppDelegate.swift ├── Base.lproj │ └── LaunchScreen.xib ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── SecondStoryboard.storyboard └── SecondViewController.swift └── iOS_Swift_ColorPicker_Storyboard ├── AppDelegate.swift ├── Base.lproj └── LaunchScreen.xib ├── FirstStoryboard.storyboard ├── FirstViewController.swift ├── Images.xcassets └── AppIcon.appiconset │ └── Contents.json └── Info.plist /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Christian Zimmermann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS ColorPicker 2 | **Written completely in Swift**. 3 | 4 | ![ColorPicker ScreenShot](../master/Screenshots/Image01_Thumb.png) 5 | 6 | ## Overview 7 | The Color Picker constist of a ``SwiftColorView`` and a ``SwiftColorPickerViewController``. By Tapping or panning on the view the ``SwiftColorPickerDelegate`` is notfied about the changed color. 8 | 9 | To customize the colors displayed by the ``SwiftColorPickerViewController`` implement the ``SwiftColorPickerDataSource`` protocoll and the caller class as the `dataSource` of the ``SwiftColorPickerViewController``. 10 | 11 | In the Repository are two Example projects, which show how to utilize the ``SwiftColorPickerViewController``. 12 | 13 | - Using the ViewController in a storyboard 14 | - Creating and using the ViewController programmatically 15 | 16 | The ``SwiftColorView``is ``@IBDesignable``so it will render nicely in InterfaceBuilder. 17 | 18 | ![SwiftColorView in InterfaceBuilder](../master/Screenshots/Image02_Thumb.png) 19 | 20 | 21 | ## Usage 22 | Copy the ``SwiftColorPickerViewController.swift``into your project. 23 | 24 | ### Add ViewController in a Storyboard 25 | + Add a View Controller 26 | + Set View Class to ``SwiftColorPickerViewController`` 27 | + Select View and set Class of View to ``SwiftColorView`` 28 | 29 | https://www.youtube.com/watch?v=VtV5bI_UBo4 30 | 31 | You can change the porpertis of the ``SwiftColorView``in the inspector. 32 | 33 | ### Add ViewController Programmatically 34 | 35 | + Instantiate a picker object 36 | + add a delegate 37 | 38 | ``let colorPickerVC = SwiftColorPickerViewController()`` 39 | 40 | ``colorPickerVC.delegate = self`` 41 | 42 | + (optional) add a dataSource 43 | 44 | ``colorPickerVC.dataSource = self`` 45 | 46 | **Parameters:** 47 | 48 | + Number of color blocks in x-direction. Color palette size is numberColorsInXDirection * numberColorsInYDirection 49 | 50 | `` colorPickerVC.numberColorsInXDirection = 20;`` 51 | 52 | + Number of color blocks in y-direction. Color palette size is numberColorsInXDirection * numberColorsInYDirection 53 | 54 | ``colorPickerVC.numberColorsInYDirection = 20;`` 55 | 56 | + Width of the edge around the color palette. The border change the color with the selection by the user. Default is 10 57 | 58 | ``colorPickerVC.coloredBorderWidth = 10;`` 59 | 60 | + Diameter of the circular view, which preview the color selection. The preview will apear at the fimnger tip of the users touch and show se current selected color. 61 | 62 | ``colorPickerVC.colorPreviewDiameter = 44;`` 63 | 64 | 65 | ## More 66 | 67 | If you like the code write me. 68 | -------------------------------------------------------------------------------- /Screenshots/Image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Christian1313/iOS_Swift_ColorPicker/36883323aa6aefd3f9a76013d91e04d41b4a240f/Screenshots/Image01.png -------------------------------------------------------------------------------- /Screenshots/Image01_Thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Christian1313/iOS_Swift_ColorPicker/36883323aa6aefd3f9a76013d91e04d41b4a240f/Screenshots/Image01_Thumb.png -------------------------------------------------------------------------------- /Screenshots/Image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Christian1313/iOS_Swift_ColorPicker/36883323aa6aefd3f9a76013d91e04d41b4a240f/Screenshots/Image02.png -------------------------------------------------------------------------------- /Screenshots/Image02_Thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Christian1313/iOS_Swift_ColorPicker/36883323aa6aefd3f9a76013d91e04d41b4a240f/Screenshots/Image02_Thumb.png -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D610BB401AA6020C00864138 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D610BB3F1AA6020C00864138 /* AppDelegate.swift */; }; 11 | D610BB471AA6020C00864138 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D610BB461AA6020C00864138 /* Images.xcassets */; }; 12 | D610BB4A1AA6020C00864138 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D610BB481AA6020C00864138 /* LaunchScreen.xib */; }; 13 | D610BB6A1AA603B300864138 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D610BB691AA603B300864138 /* AppDelegate.swift */; }; 14 | D610BB711AA603B300864138 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D610BB701AA603B300864138 /* Images.xcassets */; }; 15 | D610BB741AA603B300864138 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D610BB721AA603B300864138 /* LaunchScreen.xib */; }; 16 | D610BB911AA6040200864138 /* iOS_Swift_ColorPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = D610BB901AA6040200864138 /* iOS_Swift_ColorPicker.h */; settings = {ATTRIBUTES = (Public, ); }; }; 17 | D610BBA31AA6040200864138 /* iOS_Swift_ColorPicker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D610BB8C1AA6040100864138 /* iOS_Swift_ColorPicker.framework */; }; 18 | D610BBA41AA6040200864138 /* iOS_Swift_ColorPicker.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D610BB8C1AA6040100864138 /* iOS_Swift_ColorPicker.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 19 | D610BBAD1AA6045F00864138 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D610BBAC1AA6045F00864138 /* FirstViewController.swift */; }; 20 | D610BBAF1AA6047200864138 /* FirstStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D610BBAE1AA6047200864138 /* FirstStoryboard.storyboard */; }; 21 | D610BBB11AA604AD00864138 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D610BBB01AA604AD00864138 /* SecondViewController.swift */; }; 22 | D610BBB31AA604C300864138 /* SecondStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D610BBB21AA604C300864138 /* SecondStoryboard.storyboard */; }; 23 | D610BBB51AA604E100864138 /* SwiftColorPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D610BBB41AA604E100864138 /* SwiftColorPickerViewController.swift */; }; 24 | D610BBB61AA604F700864138 /* SwiftColorPickerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D610BBB41AA604E100864138 /* SwiftColorPickerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 25 | D610BBB71AA6146C00864138 /* iOS_Swift_ColorPicker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D610BB8C1AA6040100864138 /* iOS_Swift_ColorPicker.framework */; }; 26 | D610BBB91AA6147A00864138 /* iOS_Swift_ColorPicker.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D610BB8C1AA6040100864138 /* iOS_Swift_ColorPicker.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | D610BBA11AA6040200864138 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = D610BB0A1AA601C700864138 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = D610BB8B1AA6040100864138; 35 | remoteInfo = iOS_Swift_ColorPicker; 36 | }; 37 | D610BBBA1AA6147A00864138 /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = D610BB0A1AA601C700864138 /* Project object */; 40 | proxyType = 1; 41 | remoteGlobalIDString = D610BB8B1AA6040100864138; 42 | remoteInfo = iOS_Swift_ColorPicker; 43 | }; 44 | /* End PBXContainerItemProxy section */ 45 | 46 | /* Begin PBXCopyFilesBuildPhase section */ 47 | D610BBA81AA6040200864138 /* Embed Frameworks */ = { 48 | isa = PBXCopyFilesBuildPhase; 49 | buildActionMask = 2147483647; 50 | dstPath = ""; 51 | dstSubfolderSpec = 10; 52 | files = ( 53 | D610BBA41AA6040200864138 /* iOS_Swift_ColorPicker.framework in Embed Frameworks */, 54 | ); 55 | name = "Embed Frameworks"; 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | D610BBBC1AA6147A00864138 /* Embed Frameworks */ = { 59 | isa = PBXCopyFilesBuildPhase; 60 | buildActionMask = 2147483647; 61 | dstPath = ""; 62 | dstSubfolderSpec = 10; 63 | files = ( 64 | D610BBB91AA6147A00864138 /* iOS_Swift_ColorPicker.framework in Embed Frameworks */, 65 | ); 66 | name = "Embed Frameworks"; 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXCopyFilesBuildPhase section */ 70 | 71 | /* Begin PBXFileReference section */ 72 | D610BB3B1AA6020C00864138 /* iOS_Swift_ColorPicker_Programmatically.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOS_Swift_ColorPicker_Programmatically.app; sourceTree = BUILT_PRODUCTS_DIR; }; 73 | D610BB3E1AA6020C00864138 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 74 | D610BB3F1AA6020C00864138 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 75 | D610BB461AA6020C00864138 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 76 | D610BB491AA6020C00864138 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 77 | D610BB651AA603B300864138 /* iOS_Swift_ColorPicker_Storyboard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOS_Swift_ColorPicker_Storyboard.app; sourceTree = BUILT_PRODUCTS_DIR; }; 78 | D610BB681AA603B300864138 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 79 | D610BB691AA603B300864138 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 80 | D610BB701AA603B300864138 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 81 | D610BB731AA603B300864138 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 82 | D610BB8C1AA6040100864138 /* iOS_Swift_ColorPicker.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = iOS_Swift_ColorPicker.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 83 | D610BB8F1AA6040200864138 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 84 | D610BB901AA6040200864138 /* iOS_Swift_ColorPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = iOS_Swift_ColorPicker.h; sourceTree = ""; }; 85 | D610BBAC1AA6045F00864138 /* FirstViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = ""; }; 86 | D610BBAE1AA6047200864138 /* FirstStoryboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = FirstStoryboard.storyboard; sourceTree = ""; }; 87 | D610BBB01AA604AD00864138 /* SecondViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; 88 | D610BBB21AA604C300864138 /* SecondStoryboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = SecondStoryboard.storyboard; sourceTree = ""; }; 89 | D610BBB41AA604E100864138 /* SwiftColorPickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftColorPickerViewController.swift; sourceTree = ""; }; 90 | D610BBBD1AA7572800864138 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 91 | /* End PBXFileReference section */ 92 | 93 | /* Begin PBXFrameworksBuildPhase section */ 94 | D610BB381AA6020C00864138 /* Frameworks */ = { 95 | isa = PBXFrameworksBuildPhase; 96 | buildActionMask = 2147483647; 97 | files = ( 98 | D610BBB71AA6146C00864138 /* iOS_Swift_ColorPicker.framework in Frameworks */, 99 | ); 100 | runOnlyForDeploymentPostprocessing = 0; 101 | }; 102 | D610BB621AA603B300864138 /* Frameworks */ = { 103 | isa = PBXFrameworksBuildPhase; 104 | buildActionMask = 2147483647; 105 | files = ( 106 | D610BBA31AA6040200864138 /* iOS_Swift_ColorPicker.framework in Frameworks */, 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | D610BB881AA6040100864138 /* Frameworks */ = { 111 | isa = PBXFrameworksBuildPhase; 112 | buildActionMask = 2147483647; 113 | files = ( 114 | ); 115 | runOnlyForDeploymentPostprocessing = 0; 116 | }; 117 | /* End PBXFrameworksBuildPhase section */ 118 | 119 | /* Begin PBXGroup section */ 120 | D610BB091AA601C700864138 = { 121 | isa = PBXGroup; 122 | children = ( 123 | D610BBBD1AA7572800864138 /* README.md */, 124 | D610BB661AA603B300864138 /* iOS_Swift_ColorPicker_Storyboard */, 125 | D610BB3C1AA6020C00864138 /* iOS_Swift_ColorPicker_Programmatically */, 126 | D610BB8D1AA6040200864138 /* iOS_Swift_ColorPicker */, 127 | D610BB131AA601C700864138 /* Products */, 128 | ); 129 | sourceTree = ""; 130 | }; 131 | D610BB131AA601C700864138 /* Products */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | D610BB3B1AA6020C00864138 /* iOS_Swift_ColorPicker_Programmatically.app */, 135 | D610BB651AA603B300864138 /* iOS_Swift_ColorPicker_Storyboard.app */, 136 | D610BB8C1AA6040100864138 /* iOS_Swift_ColorPicker.framework */, 137 | ); 138 | name = Products; 139 | sourceTree = ""; 140 | }; 141 | D610BB3C1AA6020C00864138 /* iOS_Swift_ColorPicker_Programmatically */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | D610BB3F1AA6020C00864138 /* AppDelegate.swift */, 145 | D610BBB01AA604AD00864138 /* SecondViewController.swift */, 146 | D610BBB21AA604C300864138 /* SecondStoryboard.storyboard */, 147 | D610BB461AA6020C00864138 /* Images.xcassets */, 148 | D610BB481AA6020C00864138 /* LaunchScreen.xib */, 149 | D610BB3D1AA6020C00864138 /* Supporting Files */, 150 | ); 151 | path = iOS_Swift_ColorPicker_Programmatically; 152 | sourceTree = ""; 153 | }; 154 | D610BB3D1AA6020C00864138 /* Supporting Files */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | D610BB3E1AA6020C00864138 /* Info.plist */, 158 | ); 159 | name = "Supporting Files"; 160 | sourceTree = ""; 161 | }; 162 | D610BB661AA603B300864138 /* iOS_Swift_ColorPicker_Storyboard */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | D610BB691AA603B300864138 /* AppDelegate.swift */, 166 | D610BBAC1AA6045F00864138 /* FirstViewController.swift */, 167 | D610BBAE1AA6047200864138 /* FirstStoryboard.storyboard */, 168 | D610BB701AA603B300864138 /* Images.xcassets */, 169 | D610BB721AA603B300864138 /* LaunchScreen.xib */, 170 | D610BB671AA603B300864138 /* Supporting Files */, 171 | ); 172 | path = iOS_Swift_ColorPicker_Storyboard; 173 | sourceTree = ""; 174 | }; 175 | D610BB671AA603B300864138 /* Supporting Files */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | D610BB681AA603B300864138 /* Info.plist */, 179 | ); 180 | name = "Supporting Files"; 181 | sourceTree = ""; 182 | }; 183 | D610BB8D1AA6040200864138 /* iOS_Swift_ColorPicker */ = { 184 | isa = PBXGroup; 185 | children = ( 186 | D610BB901AA6040200864138 /* iOS_Swift_ColorPicker.h */, 187 | D610BBB41AA604E100864138 /* SwiftColorPickerViewController.swift */, 188 | D610BB8E1AA6040200864138 /* Supporting Files */, 189 | ); 190 | path = iOS_Swift_ColorPicker; 191 | sourceTree = ""; 192 | }; 193 | D610BB8E1AA6040200864138 /* Supporting Files */ = { 194 | isa = PBXGroup; 195 | children = ( 196 | D610BB8F1AA6040200864138 /* Info.plist */, 197 | ); 198 | name = "Supporting Files"; 199 | sourceTree = ""; 200 | }; 201 | /* End PBXGroup section */ 202 | 203 | /* Begin PBXHeadersBuildPhase section */ 204 | D610BB891AA6040100864138 /* Headers */ = { 205 | isa = PBXHeadersBuildPhase; 206 | buildActionMask = 2147483647; 207 | files = ( 208 | D610BBB61AA604F700864138 /* SwiftColorPickerViewController.swift in Headers */, 209 | D610BB911AA6040200864138 /* iOS_Swift_ColorPicker.h in Headers */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXHeadersBuildPhase section */ 214 | 215 | /* Begin PBXNativeTarget section */ 216 | D610BB3A1AA6020C00864138 /* iOS_Swift_ColorPicker_Programmatically */ = { 217 | isa = PBXNativeTarget; 218 | buildConfigurationList = D610BB571AA6020C00864138 /* Build configuration list for PBXNativeTarget "iOS_Swift_ColorPicker_Programmatically" */; 219 | buildPhases = ( 220 | D610BB371AA6020C00864138 /* Sources */, 221 | D610BB381AA6020C00864138 /* Frameworks */, 222 | D610BB391AA6020C00864138 /* Resources */, 223 | D610BBBC1AA6147A00864138 /* Embed Frameworks */, 224 | ); 225 | buildRules = ( 226 | ); 227 | dependencies = ( 228 | D610BBBB1AA6147A00864138 /* PBXTargetDependency */, 229 | ); 230 | name = iOS_Swift_ColorPicker_Programmatically; 231 | productName = iOS_Swift_ColorPicker_Programmatically; 232 | productReference = D610BB3B1AA6020C00864138 /* iOS_Swift_ColorPicker_Programmatically.app */; 233 | productType = "com.apple.product-type.application"; 234 | }; 235 | D610BB641AA603B300864138 /* iOS_Swift_ColorPicker_Storyboard */ = { 236 | isa = PBXNativeTarget; 237 | buildConfigurationList = D610BB811AA603B300864138 /* Build configuration list for PBXNativeTarget "iOS_Swift_ColorPicker_Storyboard" */; 238 | buildPhases = ( 239 | D610BB611AA603B300864138 /* Sources */, 240 | D610BB621AA603B300864138 /* Frameworks */, 241 | D610BB631AA603B300864138 /* Resources */, 242 | D610BBA81AA6040200864138 /* Embed Frameworks */, 243 | ); 244 | buildRules = ( 245 | ); 246 | dependencies = ( 247 | D610BBA21AA6040200864138 /* PBXTargetDependency */, 248 | ); 249 | name = iOS_Swift_ColorPicker_Storyboard; 250 | productName = iOS_Swift_ColorPicker_Storyboard; 251 | productReference = D610BB651AA603B300864138 /* iOS_Swift_ColorPicker_Storyboard.app */; 252 | productType = "com.apple.product-type.application"; 253 | }; 254 | D610BB8B1AA6040100864138 /* iOS_Swift_ColorPicker */ = { 255 | isa = PBXNativeTarget; 256 | buildConfigurationList = D610BBA51AA6040200864138 /* Build configuration list for PBXNativeTarget "iOS_Swift_ColorPicker" */; 257 | buildPhases = ( 258 | D610BB871AA6040100864138 /* Sources */, 259 | D610BB881AA6040100864138 /* Frameworks */, 260 | D610BB891AA6040100864138 /* Headers */, 261 | D610BB8A1AA6040100864138 /* Resources */, 262 | ); 263 | buildRules = ( 264 | ); 265 | dependencies = ( 266 | ); 267 | name = iOS_Swift_ColorPicker; 268 | productName = iOS_Swift_ColorPicker; 269 | productReference = D610BB8C1AA6040100864138 /* iOS_Swift_ColorPicker.framework */; 270 | productType = "com.apple.product-type.framework"; 271 | }; 272 | /* End PBXNativeTarget section */ 273 | 274 | /* Begin PBXProject section */ 275 | D610BB0A1AA601C700864138 /* Project object */ = { 276 | isa = PBXProject; 277 | attributes = { 278 | LastSwiftUpdateCheck = 0700; 279 | LastUpgradeCheck = 0700; 280 | ORGANIZATIONNAME = "Christian Zimmermann"; 281 | TargetAttributes = { 282 | D610BB3A1AA6020C00864138 = { 283 | CreatedOnToolsVersion = 6.1.1; 284 | }; 285 | D610BB641AA603B300864138 = { 286 | CreatedOnToolsVersion = 6.1.1; 287 | }; 288 | D610BB8B1AA6040100864138 = { 289 | CreatedOnToolsVersion = 6.1.1; 290 | }; 291 | }; 292 | }; 293 | buildConfigurationList = D610BB0D1AA601C700864138 /* Build configuration list for PBXProject "iOS_Swift_ColorPicker" */; 294 | compatibilityVersion = "Xcode 3.2"; 295 | developmentRegion = English; 296 | hasScannedForEncodings = 0; 297 | knownRegions = ( 298 | en, 299 | Base, 300 | ); 301 | mainGroup = D610BB091AA601C700864138; 302 | productRefGroup = D610BB131AA601C700864138 /* Products */; 303 | projectDirPath = ""; 304 | projectRoot = ""; 305 | targets = ( 306 | D610BB641AA603B300864138 /* iOS_Swift_ColorPicker_Storyboard */, 307 | D610BB3A1AA6020C00864138 /* iOS_Swift_ColorPicker_Programmatically */, 308 | D610BB8B1AA6040100864138 /* iOS_Swift_ColorPicker */, 309 | ); 310 | }; 311 | /* End PBXProject section */ 312 | 313 | /* Begin PBXResourcesBuildPhase section */ 314 | D610BB391AA6020C00864138 /* Resources */ = { 315 | isa = PBXResourcesBuildPhase; 316 | buildActionMask = 2147483647; 317 | files = ( 318 | D610BB4A1AA6020C00864138 /* LaunchScreen.xib in Resources */, 319 | D610BBB31AA604C300864138 /* SecondStoryboard.storyboard in Resources */, 320 | D610BB471AA6020C00864138 /* Images.xcassets in Resources */, 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | }; 324 | D610BB631AA603B300864138 /* Resources */ = { 325 | isa = PBXResourcesBuildPhase; 326 | buildActionMask = 2147483647; 327 | files = ( 328 | D610BB741AA603B300864138 /* LaunchScreen.xib in Resources */, 329 | D610BBAF1AA6047200864138 /* FirstStoryboard.storyboard in Resources */, 330 | D610BB711AA603B300864138 /* Images.xcassets in Resources */, 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | }; 334 | D610BB8A1AA6040100864138 /* Resources */ = { 335 | isa = PBXResourcesBuildPhase; 336 | buildActionMask = 2147483647; 337 | files = ( 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | /* End PBXResourcesBuildPhase section */ 342 | 343 | /* Begin PBXSourcesBuildPhase section */ 344 | D610BB371AA6020C00864138 /* Sources */ = { 345 | isa = PBXSourcesBuildPhase; 346 | buildActionMask = 2147483647; 347 | files = ( 348 | D610BBB11AA604AD00864138 /* SecondViewController.swift in Sources */, 349 | D610BB401AA6020C00864138 /* AppDelegate.swift in Sources */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | D610BB611AA603B300864138 /* Sources */ = { 354 | isa = PBXSourcesBuildPhase; 355 | buildActionMask = 2147483647; 356 | files = ( 357 | D610BBAD1AA6045F00864138 /* FirstViewController.swift in Sources */, 358 | D610BB6A1AA603B300864138 /* AppDelegate.swift in Sources */, 359 | ); 360 | runOnlyForDeploymentPostprocessing = 0; 361 | }; 362 | D610BB871AA6040100864138 /* Sources */ = { 363 | isa = PBXSourcesBuildPhase; 364 | buildActionMask = 2147483647; 365 | files = ( 366 | D610BBB51AA604E100864138 /* SwiftColorPickerViewController.swift in Sources */, 367 | ); 368 | runOnlyForDeploymentPostprocessing = 0; 369 | }; 370 | /* End PBXSourcesBuildPhase section */ 371 | 372 | /* Begin PBXTargetDependency section */ 373 | D610BBA21AA6040200864138 /* PBXTargetDependency */ = { 374 | isa = PBXTargetDependency; 375 | target = D610BB8B1AA6040100864138 /* iOS_Swift_ColorPicker */; 376 | targetProxy = D610BBA11AA6040200864138 /* PBXContainerItemProxy */; 377 | }; 378 | D610BBBB1AA6147A00864138 /* PBXTargetDependency */ = { 379 | isa = PBXTargetDependency; 380 | target = D610BB8B1AA6040100864138 /* iOS_Swift_ColorPicker */; 381 | targetProxy = D610BBBA1AA6147A00864138 /* PBXContainerItemProxy */; 382 | }; 383 | /* End PBXTargetDependency section */ 384 | 385 | /* Begin PBXVariantGroup section */ 386 | D610BB481AA6020C00864138 /* LaunchScreen.xib */ = { 387 | isa = PBXVariantGroup; 388 | children = ( 389 | D610BB491AA6020C00864138 /* Base */, 390 | ); 391 | name = LaunchScreen.xib; 392 | sourceTree = ""; 393 | }; 394 | D610BB721AA603B300864138 /* LaunchScreen.xib */ = { 395 | isa = PBXVariantGroup; 396 | children = ( 397 | D610BB731AA603B300864138 /* Base */, 398 | ); 399 | name = LaunchScreen.xib; 400 | sourceTree = ""; 401 | }; 402 | /* End PBXVariantGroup section */ 403 | 404 | /* Begin XCBuildConfiguration section */ 405 | D610BB2F1AA601C800864138 /* Debug */ = { 406 | isa = XCBuildConfiguration; 407 | buildSettings = { 408 | ALWAYS_SEARCH_USER_PATHS = NO; 409 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 410 | CLANG_CXX_LIBRARY = "libc++"; 411 | CLANG_ENABLE_MODULES = YES; 412 | CLANG_ENABLE_OBJC_ARC = YES; 413 | CLANG_WARN_BOOL_CONVERSION = YES; 414 | CLANG_WARN_CONSTANT_CONVERSION = YES; 415 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 416 | CLANG_WARN_EMPTY_BODY = YES; 417 | CLANG_WARN_ENUM_CONVERSION = YES; 418 | CLANG_WARN_INT_CONVERSION = YES; 419 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 420 | CLANG_WARN_UNREACHABLE_CODE = YES; 421 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 422 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 423 | COPY_PHASE_STRIP = NO; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | ENABLE_TESTABILITY = YES; 426 | GCC_C_LANGUAGE_STANDARD = gnu99; 427 | GCC_DYNAMIC_NO_PIC = NO; 428 | GCC_OPTIMIZATION_LEVEL = 0; 429 | GCC_PREPROCESSOR_DEFINITIONS = ( 430 | "DEBUG=1", 431 | "$(inherited)", 432 | ); 433 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 434 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 435 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 436 | GCC_WARN_UNDECLARED_SELECTOR = YES; 437 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 438 | GCC_WARN_UNUSED_FUNCTION = YES; 439 | GCC_WARN_UNUSED_VARIABLE = YES; 440 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 441 | MTL_ENABLE_DEBUG_INFO = YES; 442 | ONLY_ACTIVE_ARCH = YES; 443 | SDKROOT = iphoneos; 444 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 445 | TARGETED_DEVICE_FAMILY = "1,2"; 446 | }; 447 | name = Debug; 448 | }; 449 | D610BB301AA601C800864138 /* Release */ = { 450 | isa = XCBuildConfiguration; 451 | buildSettings = { 452 | ALWAYS_SEARCH_USER_PATHS = NO; 453 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 454 | CLANG_CXX_LIBRARY = "libc++"; 455 | CLANG_ENABLE_MODULES = YES; 456 | CLANG_ENABLE_OBJC_ARC = YES; 457 | CLANG_WARN_BOOL_CONVERSION = YES; 458 | CLANG_WARN_CONSTANT_CONVERSION = YES; 459 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 460 | CLANG_WARN_EMPTY_BODY = YES; 461 | CLANG_WARN_ENUM_CONVERSION = YES; 462 | CLANG_WARN_INT_CONVERSION = YES; 463 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 464 | CLANG_WARN_UNREACHABLE_CODE = YES; 465 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 466 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 467 | COPY_PHASE_STRIP = YES; 468 | ENABLE_NS_ASSERTIONS = NO; 469 | ENABLE_STRICT_OBJC_MSGSEND = YES; 470 | GCC_C_LANGUAGE_STANDARD = gnu99; 471 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 472 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 473 | GCC_WARN_UNDECLARED_SELECTOR = YES; 474 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 475 | GCC_WARN_UNUSED_FUNCTION = YES; 476 | GCC_WARN_UNUSED_VARIABLE = YES; 477 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 478 | MTL_ENABLE_DEBUG_INFO = NO; 479 | SDKROOT = iphoneos; 480 | TARGETED_DEVICE_FAMILY = "1,2"; 481 | VALIDATE_PRODUCT = YES; 482 | }; 483 | name = Release; 484 | }; 485 | D610BB581AA6020C00864138 /* Debug */ = { 486 | isa = XCBuildConfiguration; 487 | buildSettings = { 488 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 489 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 490 | GCC_PREPROCESSOR_DEFINITIONS = ( 491 | "DEBUG=1", 492 | "$(inherited)", 493 | ); 494 | INFOPLIST_FILE = iOS_Swift_ColorPicker_Programmatically/Info.plist; 495 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 496 | PRODUCT_BUNDLE_IDENTIFIER = "com.justplainapps.com.$(PRODUCT_NAME:rfc1034identifier)"; 497 | PRODUCT_NAME = "$(TARGET_NAME)"; 498 | }; 499 | name = Debug; 500 | }; 501 | D610BB591AA6020C00864138 /* Release */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 505 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 506 | INFOPLIST_FILE = iOS_Swift_ColorPicker_Programmatically/Info.plist; 507 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 508 | PRODUCT_BUNDLE_IDENTIFIER = "com.justplainapps.com.$(PRODUCT_NAME:rfc1034identifier)"; 509 | PRODUCT_NAME = "$(TARGET_NAME)"; 510 | }; 511 | name = Release; 512 | }; 513 | D610BB821AA603B300864138 /* Debug */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 517 | GCC_PREPROCESSOR_DEFINITIONS = ( 518 | "DEBUG=1", 519 | "$(inherited)", 520 | ); 521 | INFOPLIST_FILE = iOS_Swift_ColorPicker_Storyboard/Info.plist; 522 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 523 | PRODUCT_BUNDLE_IDENTIFIER = "com.justplainapps.com.$(PRODUCT_NAME:rfc1034identifier)"; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | }; 526 | name = Debug; 527 | }; 528 | D610BB831AA603B300864138 /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | buildSettings = { 531 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 532 | INFOPLIST_FILE = iOS_Swift_ColorPicker_Storyboard/Info.plist; 533 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 534 | PRODUCT_BUNDLE_IDENTIFIER = "com.justplainapps.com.$(PRODUCT_NAME:rfc1034identifier)"; 535 | PRODUCT_NAME = "$(TARGET_NAME)"; 536 | }; 537 | name = Release; 538 | }; 539 | D610BBA61AA6040200864138 /* Debug */ = { 540 | isa = XCBuildConfiguration; 541 | buildSettings = { 542 | CLANG_ENABLE_MODULES = YES; 543 | CURRENT_PROJECT_VERSION = 1; 544 | DEFINES_MODULE = YES; 545 | DYLIB_COMPATIBILITY_VERSION = 1; 546 | DYLIB_CURRENT_VERSION = 1; 547 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 548 | GCC_PREPROCESSOR_DEFINITIONS = ( 549 | "DEBUG=1", 550 | "$(inherited)", 551 | ); 552 | INFOPLIST_FILE = iOS_Swift_ColorPicker/Info.plist; 553 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 554 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 555 | PRODUCT_BUNDLE_IDENTIFIER = "com.justplainapps.com.$(PRODUCT_NAME:rfc1034identifier)"; 556 | PRODUCT_NAME = "$(TARGET_NAME)"; 557 | SKIP_INSTALL = YES; 558 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 559 | VERSIONING_SYSTEM = "apple-generic"; 560 | VERSION_INFO_PREFIX = ""; 561 | }; 562 | name = Debug; 563 | }; 564 | D610BBA71AA6040200864138 /* Release */ = { 565 | isa = XCBuildConfiguration; 566 | buildSettings = { 567 | CLANG_ENABLE_MODULES = YES; 568 | CURRENT_PROJECT_VERSION = 1; 569 | DEFINES_MODULE = YES; 570 | DYLIB_COMPATIBILITY_VERSION = 1; 571 | DYLIB_CURRENT_VERSION = 1; 572 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 573 | INFOPLIST_FILE = iOS_Swift_ColorPicker/Info.plist; 574 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 575 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 576 | PRODUCT_BUNDLE_IDENTIFIER = "com.justplainapps.com.$(PRODUCT_NAME:rfc1034identifier)"; 577 | PRODUCT_NAME = "$(TARGET_NAME)"; 578 | SKIP_INSTALL = YES; 579 | VERSIONING_SYSTEM = "apple-generic"; 580 | VERSION_INFO_PREFIX = ""; 581 | }; 582 | name = Release; 583 | }; 584 | /* End XCBuildConfiguration section */ 585 | 586 | /* Begin XCConfigurationList section */ 587 | D610BB0D1AA601C700864138 /* Build configuration list for PBXProject "iOS_Swift_ColorPicker" */ = { 588 | isa = XCConfigurationList; 589 | buildConfigurations = ( 590 | D610BB2F1AA601C800864138 /* Debug */, 591 | D610BB301AA601C800864138 /* Release */, 592 | ); 593 | defaultConfigurationIsVisible = 0; 594 | defaultConfigurationName = Release; 595 | }; 596 | D610BB571AA6020C00864138 /* Build configuration list for PBXNativeTarget "iOS_Swift_ColorPicker_Programmatically" */ = { 597 | isa = XCConfigurationList; 598 | buildConfigurations = ( 599 | D610BB581AA6020C00864138 /* Debug */, 600 | D610BB591AA6020C00864138 /* Release */, 601 | ); 602 | defaultConfigurationIsVisible = 0; 603 | defaultConfigurationName = Release; 604 | }; 605 | D610BB811AA603B300864138 /* Build configuration list for PBXNativeTarget "iOS_Swift_ColorPicker_Storyboard" */ = { 606 | isa = XCConfigurationList; 607 | buildConfigurations = ( 608 | D610BB821AA603B300864138 /* Debug */, 609 | D610BB831AA603B300864138 /* Release */, 610 | ); 611 | defaultConfigurationIsVisible = 0; 612 | defaultConfigurationName = Release; 613 | }; 614 | D610BBA51AA6040200864138 /* Build configuration list for PBXNativeTarget "iOS_Swift_ColorPicker" */ = { 615 | isa = XCConfigurationList; 616 | buildConfigurations = ( 617 | D610BBA61AA6040200864138 /* Debug */, 618 | D610BBA71AA6040200864138 /* Release */, 619 | ); 620 | defaultConfigurationIsVisible = 0; 621 | defaultConfigurationName = Release; 622 | }; 623 | /* End XCConfigurationList section */ 624 | }; 625 | rootObject = D610BB0A1AA601C700864138 /* Project object */; 626 | } 627 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/project.xcworkspace/xcuserdata/alex_ling.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Christian1313/iOS_Swift_ColorPicker/36883323aa6aefd3f9a76013d91e04d41b4a240f/iOS_Swift_ColorPicker.xcodeproj/project.xcworkspace/xcuserdata/alex_ling.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/xcuserdata/alex_ling.xcuserdatad/xcschemes/iOS_Swift_ColorPicker.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 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/xcuserdata/alex_ling.xcuserdatad/xcschemes/iOS_Swift_ColorPicker_Programmatically.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 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/xcuserdata/alex_ling.xcuserdatad/xcschemes/iOS_Swift_ColorPicker_Storyboard.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 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/xcuserdata/alex_ling.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | iOS_Swift_ColorPicker.xcscheme 8 | 9 | orderHint 10 | 2 11 | 12 | iOS_Swift_ColorPicker_Programmatically.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | iOS_Swift_ColorPicker_Storyboard.xcscheme 18 | 19 | orderHint 20 | 0 21 | 22 | 23 | SuppressBuildableAutocreation 24 | 25 | D610BB3A1AA6020C00864138 26 | 27 | primary 28 | 29 | 30 | D610BB641AA603B300864138 31 | 32 | primary 33 | 34 | 35 | D610BB8B1AA6040100864138 36 | 37 | primary 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker.xcodeproj/xcuserdata/christianzimmermann.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | iOS_Swift_ColorPicker.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | iOS_Swift_ColorPicker.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 2 16 | 17 | iOS_Swift_ColorPicker_Programmatically.xcscheme 18 | 19 | orderHint 20 | 2 21 | 22 | iOS_Swift_ColorPicker_Storyboard.xcscheme 23 | 24 | orderHint 25 | 0 26 | 27 | 28 | SuppressBuildableAutocreation 29 | 30 | D610BB111AA601C700864138 31 | 32 | primary 33 | 34 | 35 | D610BB261AA601C800864138 36 | 37 | primary 38 | 39 | 40 | D610BB3A1AA6020C00864138 41 | 42 | primary 43 | 44 | 45 | D610BB4E1AA6020C00864138 46 | 47 | primary 48 | 49 | 50 | D610BB641AA603B300864138 51 | 52 | primary 53 | 54 | 55 | D610BB781AA603B300864138 56 | 57 | primary 58 | 59 | 60 | D610BB8B1AA6040100864138 61 | 62 | primary 63 | 64 | 65 | D610BB951AA6040200864138 66 | 67 | primary 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker/SwiftColorPickerViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftColorPickerViewController.swift 3 | // iOSColorPicker 4 | // 5 | // Created by Christian Zimmermann on 02.03.15. 6 | // Copyright (c) 2015 Christian Zimmermann. All rights reserved. 7 | // 8 | 9 | // Note: The 'public' infront of the classe and property declaration is needed, 10 | // because the ViewController and the View is part of an framework. 11 | 12 | import UIKit 13 | 14 | public protocol SwiftColorPickerDelegate 15 | { 16 | func colorSelectionChanged(selectedColor color: UIColor) 17 | } 18 | 19 | public protocol SwiftColorPickerDataSource: class 20 | { 21 | func colorForPalletIndex(x: Int, y: Int, numXStripes: Int, numYStripes: Int) -> UIColor 22 | } 23 | 24 | /// Color Picker ViewController. Let the user pick a color from a 2D color palette. 25 | /// The delegate (SwiftColorPickerDelegate) will be notified about the color selection change. 26 | /// The user can simply tap a color or pan over the palette. When panning over the palette a round preview 27 | /// view will appear and show the current selected colot. 28 | final public class SwiftColorPickerViewController: UIViewController 29 | { 30 | /// Delegate of the SwiftColorPickerViewController 31 | public var delegate: SwiftColorPickerDelegate? 32 | 33 | /// Data Source of the SwiftColorPickerViewController 34 | public weak var dataSource: SwiftColorPickerDataSource? { 35 | didSet { 36 | colorPaletteView.viewDataSource = dataSource 37 | } 38 | } 39 | 40 | /// Width of the edge around the color palette. 41 | /// 42 | /// The border change the color with the selection by the user. 43 | /// 44 | /// Default is 10 45 | public var coloredBorderWidth:Int = 10 { 46 | didSet { 47 | colorPaletteView.coloredBorderWidth = coloredBorderWidth 48 | } 49 | } 50 | 51 | /// Diameter of the circular view, which preview the color selection. 52 | /// 53 | /// The preview will appear at the finger tip of the users touch and show the current selected color. 54 | public var colorPreviewDiameter:Int = 35 { 55 | didSet { 56 | setConstraintsForColorPreView() 57 | } 58 | } 59 | 60 | /// Number of color blocks in x-direction. 61 | /// 62 | /// Color palette size is `numberColorsInXDirection * numberColorsInYDirection` 63 | public var numberColorsInXDirection: Int = 10 { 64 | didSet { 65 | colorPaletteView.numColorsX = numberColorsInXDirection 66 | } 67 | } 68 | 69 | /// Number of color blocks in x-direction. 70 | /// 71 | /// Color palette size is `numberColorsInXDirection * numberColorsInYDirection` 72 | public var numberColorsInYDirection: Int = 18 { 73 | didSet { 74 | colorPaletteView.numColorsY = numberColorsInYDirection 75 | } 76 | } 77 | 78 | private var colorPaletteView: SwiftColorView = SwiftColorView() // is the self.view property 79 | private var colorSelectionView: UIView = UIView() 80 | 81 | private var selectionViewConstraintX: NSLayoutConstraint = NSLayoutConstraint() 82 | private var selectionViewConstraintY: NSLayoutConstraint = NSLayoutConstraint() 83 | 84 | 85 | public required override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { 86 | super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 87 | } 88 | 89 | public required init?(coder aDecoder: NSCoder) { 90 | super.init(coder: aDecoder) 91 | } 92 | 93 | public override func loadView() 94 | { 95 | super.loadView() 96 | if ( !(self.view is SwiftColorView) ) // used if the view controller ist instanciated without interface builder 97 | { 98 | let s = colorPaletteView 99 | s.translatesAutoresizingMaskIntoConstraints = false 100 | s.contentMode = UIViewContentMode.Redraw 101 | s.userInteractionEnabled = true 102 | self.view = s 103 | } 104 | else // used if in intervacebuilder the view property is set to the SwiftColorView 105 | { 106 | colorPaletteView = self.view as! SwiftColorView 107 | } 108 | coloredBorderWidth = colorPaletteView.coloredBorderWidth 109 | numberColorsInXDirection = colorPaletteView.numColorsX 110 | numberColorsInYDirection = colorPaletteView.numColorsY 111 | } 112 | 113 | public override func viewDidLoad() { 114 | super.viewDidLoad() 115 | // needed when using auto layout 116 | //colorSelectionView.setTranslatesAutoresizingMaskIntoConstraints(false) 117 | colorSelectionView.translatesAutoresizingMaskIntoConstraints = false 118 | 119 | // add subviews 120 | colorPaletteView.addSubview(colorSelectionView) 121 | // set autolayout constraints 122 | setConstraintsForColorPreView() 123 | 124 | // setup preview 125 | colorSelectionView.layer.masksToBounds = true 126 | colorSelectionView.layer.borderWidth = 0.5 127 | colorSelectionView.layer.borderColor = UIColor.grayColor().CGColor 128 | colorSelectionView.alpha = 0.0 129 | 130 | 131 | // adding gesture regocnizer 132 | let tapGr = UITapGestureRecognizer(target: self, action: "handleGestureRecognizer:") 133 | let panGr = UIPanGestureRecognizer(target: self, action: "handleGestureRecognizer:") 134 | panGr.maximumNumberOfTouches = 1 135 | colorPaletteView.addGestureRecognizer(tapGr) 136 | colorPaletteView.addGestureRecognizer(panGr) 137 | colorPaletteView.viewDataSource = dataSource 138 | } 139 | 140 | 141 | public override func touchesBegan(touches: Set, withEvent event: UIEvent?) { 142 | super.touchesBegan(touches, withEvent: event) 143 | if let touch = touches.first 144 | { 145 | let t = touch 146 | let point = t.locationInView(colorPaletteView) 147 | positionSelectorViewWithPoint(point) 148 | colorSelectionView.alpha = 1.0 149 | } 150 | } 151 | 152 | 153 | 154 | func handleGestureRecognizer(recognizer: UIGestureRecognizer) 155 | { 156 | let point = recognizer.locationInView(self.colorPaletteView) 157 | positionSelectorViewWithPoint(point) 158 | if (recognizer.state == UIGestureRecognizerState.Began) 159 | { 160 | colorSelectionView.alpha = 1.0 161 | } 162 | else if (recognizer.state == UIGestureRecognizerState.Ended) 163 | { 164 | startHidingSelectionView() 165 | } 166 | } 167 | 168 | private func setConstraintsForColorPreView() 169 | { 170 | colorPaletteView.removeConstraints(colorPaletteView.constraints) 171 | colorSelectionView.layer.cornerRadius = CGFloat(colorPreviewDiameter/2) 172 | let views = ["paletteView": self.colorPaletteView, "selectionView": colorSelectionView] 173 | 174 | var pad = 10 175 | if (colorPreviewDiameter==10) 176 | { 177 | pad = 13 178 | } 179 | 180 | let metrics = ["diameter" : colorPreviewDiameter, "pad" : pad] 181 | 182 | let constH2 = NSLayoutConstraint.constraintsWithVisualFormat("H:|-pad-[selectionView(diameter)]", options: .DirectionLeadingToTrailing, metrics: metrics, views: views) 183 | //var constH2 = NSLayoutConstraint.constraintsWithVisualFormat("H:|-pad-[selectionView(diameter)]", options: nil, metrics: metrics, views: views) 184 | 185 | 186 | //var constV2 = NSLayoutConstraint.constraintsWithVisualFormat("V:|-pad-[selectionView(diameter)]", options: nil, metrics: metrics, views: views) 187 | let constV2 = NSLayoutConstraint.constraintsWithVisualFormat("V:|-pad-[selectionView(diameter)]", options: .DirectionLeadingToTrailing, metrics: metrics, views: views) 188 | colorPaletteView.addConstraints(constH2) 189 | colorPaletteView.addConstraints(constV2) 190 | 191 | for constraint in constH2 192 | { 193 | if constraint.constant == CGFloat(pad) 194 | { 195 | selectionViewConstraintX = constraint 196 | break 197 | } 198 | } 199 | for constraint in constV2 200 | { 201 | if constraint.constant == CGFloat(pad) 202 | { 203 | selectionViewConstraintY = constraint 204 | break 205 | } 206 | } 207 | } 208 | 209 | private func positionSelectorViewWithPoint(point: CGPoint) 210 | { 211 | let colorSelected = colorPaletteView.colorAtPoint(point) 212 | delegate?.colorSelectionChanged(selectedColor: colorSelected) 213 | //self.view.backgroundColor = colorSelected 214 | colorSelectionView.backgroundColor = colorPaletteView.colorAtPoint(point) 215 | selectionViewConstraintX.constant = (point.x-colorSelectionView.bounds.size.width/2) 216 | selectionViewConstraintY.constant = (point.y-1.2*colorSelectionView.bounds.size.height) 217 | } 218 | 219 | private func startHidingSelectionView() { 220 | UIView.animateWithDuration(0.5, animations: { 221 | self.colorSelectionView.alpha = 0.0 222 | }) 223 | } 224 | } 225 | 226 | /// UIView Subclass which displays a colors in little blocks. 227 | @IBDesignable final public class SwiftColorView: UIView 228 | { 229 | /// Number of color blocks in x-direction. 230 | /// 231 | /// Color palette size is `numColorsX * numColorsY` 232 | /// 233 | /// `Default` is 10 234 | @IBInspectable public var numColorsX:Int = 10 { 235 | didSet { 236 | setNeedsDisplay() 237 | } 238 | } 239 | 240 | /// Number of color blocks in x-direction. 241 | /// 242 | /// Color palette size is `numColorsX * numColorsY` 243 | /// 244 | /// `Default` is 18 245 | @IBInspectable public var numColorsY:Int = 18 { 246 | didSet { 247 | setNeedsDisplay() 248 | } 249 | } 250 | 251 | /// Width of the edge around the color palette. 252 | /// 253 | /// The border change the color with the selection by the user. 254 | /// 255 | /// `Default` is 10 256 | @IBInspectable public var coloredBorderWidth:Int = 10 { 257 | didSet { 258 | setNeedsDisplay() 259 | } 260 | } 261 | 262 | /// Wether or not the grid between the blocks should be visible. 263 | /// 264 | /// `Default` is false 265 | @IBInspectable public var showGridLines:Bool = false { 266 | didSet { 267 | setNeedsDisplay() 268 | } 269 | } 270 | 271 | weak var viewDataSource: SwiftColorPickerDataSource? 272 | 273 | public override func drawRect(rect: CGRect) 274 | { 275 | super.drawRect(rect) 276 | let lineColor = UIColor.grayColor() 277 | let pS = patternSize() 278 | let w = pS.w 279 | let h = pS.h 280 | 281 | for y in 0.. UIColor 310 | { 311 | 312 | if let ds = viewDataSource { 313 | return ds.colorForPalletIndex(x, y: y, numXStripes: numColorsX, numYStripes: numColorsY) 314 | } else { 315 | 316 | var hue:CGFloat = CGFloat(x) / CGFloat(numColorsX) 317 | var fillColor = UIColor.whiteColor() 318 | if (y==0) 319 | { 320 | if (x==(numColorsX-1)) 321 | { 322 | hue = 1.0; 323 | } 324 | fillColor = UIColor(white: hue, alpha: 1.0); 325 | } 326 | else 327 | { 328 | let sat:CGFloat = CGFloat(1.0)-CGFloat(y-1) / CGFloat(numColorsY) 329 | fillColor = UIColor(hue: hue, saturation: sat, brightness: 1.0, alpha: 1.0) 330 | } 331 | return fillColor 332 | } 333 | } 334 | 335 | func colorAtPoint(point: CGPoint) -> UIColor 336 | { 337 | let pS = patternSize() 338 | let w = pS.w 339 | let h = pS.h 340 | let x = (point.x-CGFloat(coloredBorderWidth))/w 341 | let y = (point.y-CGFloat(coloredBorderWidth))/h 342 | return colorForRectAt(Int(x), y:Int(y)) 343 | } 344 | 345 | private func patternSize() -> (w: CGFloat, h:CGFloat) 346 | { 347 | let width = self.bounds.width-CGFloat(2*coloredBorderWidth) 348 | let height = self.bounds.height-CGFloat(2*coloredBorderWidth) 349 | 350 | let w = width/CGFloat(numColorsX) 351 | let h = height/CGFloat(numColorsY) 352 | return (w,h) 353 | } 354 | 355 | public override func prepareForInterfaceBuilder() 356 | { 357 | print("Compiled and run for IB") 358 | } 359 | 360 | } 361 | 362 | public extension UIColor { 363 | 364 | /// Random `UIColor` 365 | class func randomColor() -> UIColor { 366 | let r = CGFloat(arc4random_uniform(256))/CGFloat(255) 367 | let g = CGFloat(arc4random_uniform(256))/CGFloat(255) 368 | let b = CGFloat(arc4random_uniform(256))/CGFloat(255) 369 | let a = CGFloat(arc4random_uniform(256))/CGFloat(255) 370 | return UIColor(red: r, green: g, blue: b, alpha: a) 371 | } 372 | } 373 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker/iOS_Swift_ColorPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOS_Swift_ColorPicker.h 3 | // iOS_Swift_ColorPicker 4 | // 5 | // Created by Christian Zimmermann on 03/03/15. 6 | // Copyright (c) 2015 Christian Zimmermann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for iOS_Swift_ColorPicker. 12 | FOUNDATION_EXPORT double iOS_Swift_ColorPickerVersionNumber; 13 | 14 | //! Project version string for iOS_Swift_ColorPicker. 15 | FOUNDATION_EXPORT const unsigned char iOS_Swift_ColorPickerVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Programmatically/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // iOS_Swift_ColorPicker_Programmatically 4 | // 5 | // Created by Christian Zimmermann on 03/03/15. 6 | // Copyright (c) 2015 Christian Zimmermann. 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 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Programmatically/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Programmatically/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Programmatically/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 | SecondStoryboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Programmatically/SecondStoryboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Programmatically/SecondViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.swift 3 | // iOS_Swift_ColorPicker 4 | // 5 | // Created by Christian Zimmermann on 03/03/15. 6 | // Copyright (c) 2015 Christian Zimmermann. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import iOS_Swift_ColorPicker 11 | 12 | class SecondViewController: UIViewController, UIPopoverPresentationControllerDelegate, SwiftColorPickerDelegate, SwiftColorPickerDataSource { 13 | 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | 27 | @IBAction func showColorPickerProgrammatically(sender: UIButton) 28 | { 29 | let colorPickerVC = SwiftColorPickerViewController() 30 | colorPickerVC.delegate = self 31 | colorPickerVC.dataSource = self 32 | colorPickerVC.modalPresentationStyle = .Popover 33 | let popVC = colorPickerVC.popoverPresentationController!; 34 | popVC.sourceRect = sender.frame 35 | popVC.sourceView = self.view 36 | popVC.permittedArrowDirections = .Any; 37 | popVC.delegate = self; 38 | 39 | self.presentViewController(colorPickerVC, animated: true, completion: { 40 | print("Reade<"); 41 | }) 42 | } 43 | 44 | // MARK: popover presenation delegates 45 | 46 | // this enables pop over on iphones 47 | func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { 48 | 49 | return UIModalPresentationStyle.None 50 | } 51 | 52 | 53 | // MARK: - Color Matrix (only for test case) 54 | var colorMatrix = [ [UIColor]() ] 55 | private func fillColorMatrix(numX: Int, _ numY: Int) { 56 | 57 | colorMatrix.removeAll() 58 | if numX > 0 && numY > 0 { 59 | 60 | for _ in 0.. UIColor { 74 | if colorMatrix.count > x { 75 | let colorArray = colorMatrix[x] 76 | if colorArray.count > y { 77 | return colorArray[y] 78 | } else { 79 | fillColorMatrix(numXStripes,numYStripes) 80 | return colorForPalletIndex(x, y:y, numXStripes: numXStripes, numYStripes: numYStripes) 81 | } 82 | } else { 83 | fillColorMatrix(numXStripes,numYStripes) 84 | return colorForPalletIndex(x, y:y, numXStripes: numXStripes, numYStripes: numYStripes) 85 | } 86 | } 87 | 88 | 89 | // MARK: Color Picker Delegate 90 | 91 | func colorSelectionChanged(selectedColor color: UIColor) { 92 | 93 | self.view.backgroundColor = color 94 | } 95 | 96 | 97 | 98 | 99 | /* 100 | // MARK: - Navigation 101 | 102 | // In a storyboard-based application, you will often want to do a little preparation before navigation 103 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 104 | // Get the new view controller using segue.destinationViewController. 105 | // Pass the selected object to the new view controller. 106 | } 107 | */ 108 | 109 | } 110 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Storyboard/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // iOS_Swift_ColorPicker_Storyboard 4 | // 5 | // Created by Christian Zimmermann on 03/03/15. 6 | // Copyright (c) 2015 Christian Zimmermann. 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 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Storyboard/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Storyboard/FirstStoryboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Storyboard/FirstViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FirstViewController.swift 3 | // iOS_Swift_ColorPicker 4 | // 5 | // Created by Christian Zimmermann on 03/03/15. 6 | // Copyright (c) 2015 Christian Zimmermann. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import iOS_Swift_ColorPicker // framework with the Color Picker View Controller. XOu can simply tak the 11 | 12 | class FirstViewController: UIViewController, UIPopoverPresentationControllerDelegate, SwiftColorPickerDelegate, SwiftColorPickerDataSource 13 | { 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | } 18 | 19 | 20 | 21 | // MARK: - Segue Navigation 22 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) 23 | { 24 | if let _ = segue.identifier 25 | { 26 | // adding as delegate for color selection 27 | let colorPickerVC = segue.destinationViewController as! SwiftColorPickerViewController 28 | colorPickerVC.delegate = self 29 | colorPickerVC.dataSource = self 30 | 31 | if let popPresentationController = colorPickerVC.popoverPresentationController { 32 | popPresentationController.delegate = self 33 | } 34 | } 35 | // Get the new view controller using segue.destinationViewController. 36 | // Pass the selected object to the new view controller. 37 | } 38 | 39 | 40 | 41 | // MARK: popover presenation delegates 42 | 43 | // this enables pop over on iphones 44 | func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { 45 | 46 | return UIModalPresentationStyle.None 47 | } 48 | 49 | // MARK: - Color Matrix (only for test case) 50 | var colorMatrix = [ [UIColor]() ] 51 | private func fillColorMatrix(numX: Int, _ numY: Int) { 52 | colorMatrix.removeAll() 53 | if numX > 0 && numY > 0 { 54 | 55 | for _ in 0.. UIColor { 69 | if colorMatrix.count > x { 70 | let colorArray = colorMatrix[x] 71 | if colorArray.count > y { 72 | return colorArray[y] 73 | } else { 74 | fillColorMatrix(numXStripes,numYStripes) 75 | return colorForPalletIndex(x, y:y, numXStripes: numXStripes, numYStripes: numYStripes) 76 | } 77 | } else { 78 | fillColorMatrix(numXStripes,numYStripes) 79 | return colorForPalletIndex(x, y:y, numXStripes: numXStripes, numYStripes: numYStripes) 80 | } 81 | 82 | } 83 | 84 | 85 | 86 | // MARK: Color Picker Delegate 87 | 88 | func colorSelectionChanged(selectedColor color: UIColor) { 89 | 90 | self.view.backgroundColor = color 91 | } 92 | 93 | 94 | 95 | 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Storyboard/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /iOS_Swift_ColorPicker_Storyboard/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 | FirstStoryboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | --------------------------------------------------------------------------------