├── Gemfile
├── ColorSlider.gif
├── docs
├── img
│ ├── dash.png
│ ├── gh.png
│ └── carat.png
├── docsets
│ ├── ColorSlider.tgz
│ ├── ColorSlider.xml
│ └── ColorSlider.docset
│ │ └── Contents
│ │ ├── Resources
│ │ ├── docSet.dsidx
│ │ └── Documents
│ │ │ ├── img
│ │ │ ├── gh.png
│ │ │ ├── carat.png
│ │ │ └── dash.png
│ │ │ ├── badge.svg
│ │ │ ├── js
│ │ │ └── jazzy.js
│ │ │ ├── css
│ │ │ ├── highlight.css
│ │ │ └── jazzy.css
│ │ │ ├── Classes
│ │ │ ├── ColorSlider
│ │ │ │ └── Orientation.html
│ │ │ └── DefaultPreviewView
│ │ │ │ └── Side.html
│ │ │ ├── Protocols.html
│ │ │ ├── Enums.html
│ │ │ ├── Enums
│ │ │ ├── Orientation.html
│ │ │ └── PreviewState.html
│ │ │ ├── search.json
│ │ │ └── index.html
│ │ └── Info.plist
├── undocumented.json
├── badge.svg
├── js
│ └── jazzy.js
├── css
│ ├── highlight.css
│ └── jazzy.css
├── Classes
│ ├── ColorSlider
│ │ └── Orientation.html
│ └── DefaultPreviewView
│ │ └── Side.html
├── Protocols.html
├── Enums.html
├── Enums
│ ├── Orientation.html
│ └── PreviewState.html
├── index.html
└── search.json
├── Demo
├── ColorSliderDemo
│ ├── Spark.sks
│ ├── Assets.xcassets
│ │ ├── Particle Sprite Atlas.spriteatlas
│ │ │ ├── Contents.json
│ │ │ └── spark.imageset
│ │ │ │ ├── spark.png
│ │ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Main.storyboard
│ ├── ViewController.swift
│ ├── Info.plist
│ ├── LaunchScreen.storyboard
│ ├── AppDelegate.swift
│ └── DemoView.swift
└── ColorSliderDemo.xcodeproj
│ └── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── ColorSlider
├── ColorSlider.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── ColorSlider.xcscheme
└── Info.plist
├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── ColorSlider.podspec
├── LICENSE
├── Gemfile.lock
├── Sources
├── Internal
│ ├── ColorSliderExtensions.swift
│ ├── HSBColor.swift
│ └── Gradient.swift
├── PreviewView.swift
└── DefaultPreviewView.swift
└── README.md
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org' do
2 | gem 'cocoapods', '~> 1.6.1'
3 | end
--------------------------------------------------------------------------------
/ColorSlider.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/ColorSlider.gif
--------------------------------------------------------------------------------
/docs/img/dash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/img/dash.png
--------------------------------------------------------------------------------
/docs/img/gh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/img/gh.png
--------------------------------------------------------------------------------
/docs/img/carat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/img/carat.png
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.tgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/docsets/ColorSlider.tgz
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Spark.sks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/Demo/ColorSliderDemo/Spark.sks
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.xml:
--------------------------------------------------------------------------------
1 | 4.0 https://gizmosachin.github.io/ColorSlider/docsets/ColorSlider.tgz
2 |
--------------------------------------------------------------------------------
/docs/undocumented.json:
--------------------------------------------------------------------------------
1 | {
2 | "warnings": [
3 |
4 | ],
5 | "source_directory": "/Users/sachin/Documents/Open Source/ColorSlider/ColorSlider"
6 | }
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Assets.xcassets/Particle Sprite Atlas.spriteatlas/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/docSet.dsidx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/docsets/ColorSlider.docset/Contents/Resources/docSet.dsidx
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/img/gh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/img/gh.png
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/img/carat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/img/carat.png
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/img/dash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/img/dash.png
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | },
6 | "properties" : {
7 | "compression-type" : "gpu-optimized-smallest"
8 | }
9 | }
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Assets.xcassets/Particle Sprite Atlas.spriteatlas/spark.imageset/spark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gizmosachin/ColorSlider/HEAD/Demo/ColorSliderDemo/Assets.xcassets/Particle Sprite Atlas.spriteatlas/spark.imageset/spark.png
--------------------------------------------------------------------------------
/ColorSlider/ColorSlider.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcodeproj/*.pbxuser
3 | *.xcodeproj/*.perspectivev3
4 | *.xcworkspace/xcuserdata/
5 | *.xcodeproj/xcuserdata/
6 | *.xcodeproj/project.xcworkspace/xcuserdata/
7 | *.xcodeproj/project.xcworkspace/contents.xcworkspacedata
8 | *.xcuserstate
9 | xcuserdata
10 | */Pods/
11 | Podfile.lock
12 | Build/
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ColorSlider/ColorSlider.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 | osx_image: xcode10.2
3 | env:
4 | global:
5 | - LC_CTYPE=en_US.UTF-8
6 | - LANG=en_US.UTF-8
7 | before_install:
8 | - bundle install
9 | script:
10 | - xcodebuild -project ColorSlider/ColorSlider.xcodeproj -scheme ColorSlider -sdk iphonesimulator12.2 build analyze
11 | - bundle exec pod lib lint --verbose
12 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ### One issue or bug per Pull Request
2 |
3 | Keep your Pull Requests small. Small PRs are easier to reason about which makes them significantly more likely to get merged.
4 |
5 | ### Issues before features
6 |
7 | If you want to add a feature, please file an [Issue](issues) first. An Issue gives us the opportunity to discuss the requirements and implications of a feature with you before you start writing code.
8 |
9 | ### Forwards compatibility
10 |
11 | Please do not write new code using deprecated APIs.
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Assets.xcassets/Particle Sprite Atlas.spriteatlas/spark.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "spark.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | },
21 | "properties" : {
22 | "compression-type" : "automatic"
23 | }
24 | }
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleIdentifier
6 | com.jazzy.colorslider
7 | CFBundleName
8 | ColorSlider
9 | DocSetPlatformFamily
10 | colorslider
11 | isDashDocset
12 |
13 | dashIndexFilePath
14 | index.html
15 | isJavaScriptEnabled
16 |
17 | DashDocSetFamily
18 | dashtoc
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/badge.svg:
--------------------------------------------------------------------------------
1 | documentation documentation 100% 100%
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/badge.svg:
--------------------------------------------------------------------------------
1 | documentation documentation 100% 100%
--------------------------------------------------------------------------------
/ColorSlider.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'ColorSlider'
3 | s.version = '4.4'
4 | s.summary = 'Snapchat-style color picker in Swift'
5 | s.homepage = 'http://github.com/gizmosachin/ColorSlider'
6 | s.license = 'MIT'
7 | s.documentation_url = 'https://gizmosachin.github.io/ColorSlider/'
8 |
9 | s.social_media_url = 'http://twitter.com/gizmosachin'
10 | s.author = { 'Sachin Patel' => 'me@gizmosachin.com' }
11 |
12 | # source
13 | s.source = { :git => 'https://github.com/gizmosachin/ColorSlider.git', :tag => s.version }
14 | s.source_files = 'Sources/**', 'Sources/Internal/**'
15 |
16 | # platform
17 | s.platform = :ios
18 | s.ios.deployment_target = '9.0'
19 | s.swift_version = '5.0'
20 |
21 | # build settings
22 | s.requires_arc = true
23 | s.frameworks = 'Foundation', 'UIKit', 'CoreGraphics', 'QuartzCore'
24 | end
25 |
--------------------------------------------------------------------------------
/ColorSlider/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 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016-Present Sachin Patel (http://gizmosachin.com/)
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 |
--------------------------------------------------------------------------------
/docs/js/jazzy.js:
--------------------------------------------------------------------------------
1 | window.jazzy = {'docset': false}
2 | if (typeof window.dash != 'undefined') {
3 | document.documentElement.className += ' dash'
4 | window.jazzy.docset = true
5 | }
6 | if (navigator.userAgent.match(/xcode/i)) {
7 | document.documentElement.className += ' xcode'
8 | window.jazzy.docset = true
9 | }
10 |
11 | // On doc load, toggle the URL hash discussion if present
12 | $(document).ready(function() {
13 | if (!window.jazzy.docset) {
14 | var linkToHash = $('a[href="' + window.location.hash +'"]');
15 | linkToHash.trigger("click");
16 | }
17 | });
18 |
19 | // On token click, toggle its discussion and animate token.marginLeft
20 | $(".token").click(function(event) {
21 | if (window.jazzy.docset) {
22 | return;
23 | }
24 | var link = $(this);
25 | var animationDuration = 300;
26 | var tokenOffset = "15px";
27 | var original = link.css('marginLeft') == tokenOffset;
28 | link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration);
29 | $content = link.parent().parent().next();
30 | $content.slideToggle(animationDuration);
31 |
32 | // Keeps the document from jumping to the hash.
33 | var href = $(this).attr('href');
34 | if (history.pushState) {
35 | history.pushState({}, '', href);
36 | } else {
37 | location.hash = href;
38 | }
39 | event.preventDefault();
40 | });
41 |
42 | // Dumb down quotes within code blocks that delimit strings instead of quotations
43 | // https://github.com/realm/jazzy/issues/714
44 | $("code q").replaceWith(function () {
45 | return ["\"", $(this).contents(), "\""];
46 | });
47 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/js/jazzy.js:
--------------------------------------------------------------------------------
1 | window.jazzy = {'docset': false}
2 | if (typeof window.dash != 'undefined') {
3 | document.documentElement.className += ' dash'
4 | window.jazzy.docset = true
5 | }
6 | if (navigator.userAgent.match(/xcode/i)) {
7 | document.documentElement.className += ' xcode'
8 | window.jazzy.docset = true
9 | }
10 |
11 | // On doc load, toggle the URL hash discussion if present
12 | $(document).ready(function() {
13 | if (!window.jazzy.docset) {
14 | var linkToHash = $('a[href="' + window.location.hash +'"]');
15 | linkToHash.trigger("click");
16 | }
17 | });
18 |
19 | // On token click, toggle its discussion and animate token.marginLeft
20 | $(".token").click(function(event) {
21 | if (window.jazzy.docset) {
22 | return;
23 | }
24 | var link = $(this);
25 | var animationDuration = 300;
26 | var tokenOffset = "15px";
27 | var original = link.css('marginLeft') == tokenOffset;
28 | link.animate({'margin-left':original ? "0px" : tokenOffset}, animationDuration);
29 | $content = link.parent().parent().next();
30 | $content.slideToggle(animationDuration);
31 |
32 | // Keeps the document from jumping to the hash.
33 | var href = $(this).attr('href');
34 | if (history.pushState) {
35 | history.pushState({}, '', href);
36 | } else {
37 | location.hash = href;
38 | }
39 | event.preventDefault();
40 | });
41 |
42 | // Dumb down quotes within code blocks that delimit strings instead of quotations
43 | // https://github.com/realm/jazzy/issues/714
44 | $("code q").replaceWith(function () {
45 | return ["\"", $(this).contents(), "\""];
46 | });
47 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // ColorSliderDemo
4 | //
5 | // Created by Sachin Patel on 9/7/17.
6 | //
7 | // The MIT License (MIT)
8 | //
9 | // Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy
12 | // of this software and associated documentation files (the "Software"), to deal
13 | // in the Software without restriction, including without limitation the rights
14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | // copies of the Software, and to permit persons to whom the Software is
16 | // furnished to do so, subject to the following conditions:
17 | //
18 | // The above copyright notice and this permission notice shall be included in all
19 | // copies or substantial portions of the Software.
20 | //
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | // SOFTWARE.
28 |
29 | import UIKit
30 | import SpriteKit
31 |
32 | class ViewController: UIViewController {
33 | let demoView = DemoView()
34 |
35 | override func viewDidLoad() {
36 | super.viewDidLoad()
37 |
38 | view.addSubview(demoView)
39 | }
40 |
41 | override func viewDidLayoutSubviews() {
42 | demoView.frame = view.bounds
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIRequiredDeviceCapabilities
26 |
27 | armv7
28 |
29 | UIStatusBarHidden
30 |
31 | UIStatusBarStyle
32 | UIStatusBarStyleLightContent
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeRight
37 | UIInterfaceOrientationLandscapeLeft
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 | UIViewControllerBasedStatusBarAppearance
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ColorSliderDemo
4 | //
5 | // Created by Sachin Patel on 1/11/15.
6 | //
7 | // The MIT License (MIT)
8 | //
9 | // Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy
12 | // of this software and associated documentation files (the "Software"), to deal
13 | // in the Software without restriction, including without limitation the rights
14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | // copies of the Software, and to permit persons to whom the Software is
16 | // furnished to do so, subject to the following conditions:
17 | //
18 | // The above copyright notice and this permission notice shall be included in all
19 | // copies or substantial portions of the Software.
20 | //
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | // SOFTWARE.
28 |
29 | import UIKit
30 |
31 | @UIApplicationMain
32 | class AppDelegate: UIResponder, UIApplicationDelegate {
33 | var window: UIWindow?
34 |
35 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
36 |
37 | window = UIWindow(frame: UIScreen.main.bounds)
38 | window?.backgroundColor = UIColor.white
39 | window?.rootViewController = ViewController()
40 | window?.makeKeyAndVisible()
41 |
42 | return true
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.0)
5 | activesupport (4.2.11.1)
6 | i18n (~> 0.7)
7 | minitest (~> 5.1)
8 | thread_safe (~> 0.3, >= 0.3.4)
9 | tzinfo (~> 1.1)
10 | atomos (0.1.3)
11 | claide (1.0.2)
12 | cocoapods (1.6.1)
13 | activesupport (>= 4.0.2, < 5)
14 | claide (>= 1.0.2, < 2.0)
15 | cocoapods-core (= 1.6.1)
16 | cocoapods-deintegrate (>= 1.0.2, < 2.0)
17 | cocoapods-downloader (>= 1.2.2, < 2.0)
18 | cocoapods-plugins (>= 1.0.0, < 2.0)
19 | cocoapods-search (>= 1.0.0, < 2.0)
20 | cocoapods-stats (>= 1.0.0, < 2.0)
21 | cocoapods-trunk (>= 1.3.1, < 2.0)
22 | cocoapods-try (>= 1.1.0, < 2.0)
23 | colored2 (~> 3.1)
24 | escape (~> 0.0.4)
25 | fourflusher (>= 2.2.0, < 3.0)
26 | gh_inspector (~> 1.0)
27 | molinillo (~> 0.6.6)
28 | nap (~> 1.0)
29 | ruby-macho (~> 1.4)
30 | xcodeproj (>= 1.8.1, < 2.0)
31 | cocoapods-core (1.6.1)
32 | activesupport (>= 4.0.2, < 6)
33 | fuzzy_match (~> 2.0.4)
34 | nap (~> 1.0)
35 | cocoapods-deintegrate (1.0.4)
36 | cocoapods-downloader (1.2.2)
37 | cocoapods-plugins (1.0.0)
38 | nap
39 | cocoapods-search (1.0.0)
40 | cocoapods-stats (1.1.0)
41 | cocoapods-trunk (1.3.1)
42 | nap (>= 0.8, < 2.0)
43 | netrc (~> 0.11)
44 | cocoapods-try (1.1.0)
45 | colored2 (3.1.2)
46 | concurrent-ruby (1.1.5)
47 | escape (0.0.4)
48 | fourflusher (2.2.0)
49 | fuzzy_match (2.0.4)
50 | gh_inspector (1.1.3)
51 | i18n (0.9.5)
52 | concurrent-ruby (~> 1.0)
53 | minitest (5.11.3)
54 | molinillo (0.6.6)
55 | nanaimo (0.2.6)
56 | nap (1.1.0)
57 | netrc (0.11.0)
58 | ruby-macho (1.4.0)
59 | thread_safe (0.3.6)
60 | tzinfo (1.2.5)
61 | thread_safe (~> 0.1)
62 | xcodeproj (1.8.2)
63 | CFPropertyList (>= 2.3.3, < 4.0)
64 | atomos (~> 0.1.3)
65 | claide (>= 1.0.2, < 2.0)
66 | colored2 (~> 3.1)
67 | nanaimo (~> 0.2.6)
68 |
69 | PLATFORMS
70 | ruby
71 |
72 | DEPENDENCIES
73 | cocoapods (~> 1.6.1)!
74 |
75 | BUNDLED WITH
76 | 1.16.2
77 |
--------------------------------------------------------------------------------
/Sources/Internal/ColorSliderExtensions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ColorSliderExtensions.swift
3 | //
4 | // Created by Sachin Patel on 5/27/17.
5 | //
6 | // The MIT License (MIT)
7 | //
8 | // Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
9 | //
10 | // Permission is hereby granted, free of charge, to any person obtaining a copy
11 | // of this software and associated documentation files (the "Software"), to deal
12 | // in the Software without restriction, including without limitation the rights
13 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | // copies of the Software, and to permit persons to whom the Software is
15 | // furnished to do so, subject to the following conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be included in all
18 | // copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | // SOFTWARE.
27 |
28 | import UIKit
29 |
30 | /// :nodoc:
31 | internal extension Range {
32 | /// Constrain a `Bound` value by `self`.
33 | /// Equivalent to max(lowerBound, min(upperBound, value)).
34 | /// - parameter value: The value to be clamped.
35 | func clamp(_ value: Bound) -> Bound {
36 | return lowerBound > value ? lowerBound
37 | : upperBound < value ? upperBound
38 | : value
39 | }
40 | }
41 |
42 | /// :nodoc:
43 | internal extension UITouch {
44 | /// Calculate the "progress" of a touch in a view with respect to an orientation.
45 | /// - parameter view: The view to be used as a frame of reference.
46 | /// - parameter orientation: The orientation with which to determine the return value.
47 | /// - returns: The percent across the `view` that the receiver's location is, relative to the `orientation`. Constrained to (0, 1).
48 | func progress(in view: UIView, withOrientation orientation: Orientation) -> CGFloat {
49 | let touchLocation = self.location(in: view)
50 | var progress: CGFloat = 0
51 |
52 | switch orientation {
53 | case .vertical:
54 | progress = touchLocation.y / view.bounds.height
55 | case .horizontal:
56 | progress = touchLocation.x / view.bounds.width
57 | }
58 |
59 | return (0.0..<1.0).clamp(progress)
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Sources/Internal/HSBColor.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HSBColor.swift
3 | //
4 | // Created by Sachin Patel on 8/11/17.
5 | //
6 | // The MIT License (MIT)
7 | //
8 | // Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
9 | //
10 | // Permission is hereby granted, free of charge, to any person obtaining a copy
11 | // of this software and associated documentation files (the "Software"), to deal
12 | // in the Software without restriction, including without limitation the rights
13 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | // copies of the Software, and to permit persons to whom the Software is
15 | // furnished to do so, subject to the following conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be included in all
18 | // copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | // SOFTWARE.
27 |
28 | import UIKit
29 |
30 | /// :nodoc:
31 | /// An [HSB](https://en.wikipedia.org/wiki/HSL_and_HSV) color value type.
32 | internal struct HSBColor: Equatable {
33 | static let black = HSBColor(hue: 0, saturation: 1, brightness: 0)
34 | static let white = HSBColor(hue: 1, saturation: 0, brightness: 1)
35 |
36 | var hue: CGFloat = 0
37 | var saturation: CGFloat = 1
38 | var brightness: CGFloat = 1
39 |
40 | var isGrayscale: Bool {
41 | return saturation == 0
42 | }
43 |
44 | init(hue: CGFloat, saturation: CGFloat, brightness: CGFloat) {
45 | self.hue = hue
46 | self.saturation = saturation
47 | self.brightness = brightness
48 | }
49 |
50 | init(color: UIColor) {
51 | color.getHue(&self.hue, saturation: &self.saturation, brightness: &self.brightness, alpha: nil)
52 | }
53 |
54 | static func between(color: HSBColor, and otherColor: HSBColor, percent: CGFloat) -> HSBColor {
55 | let hue = min(color.hue, otherColor.hue) + (abs(color.hue - otherColor.hue) * percent)
56 | let saturation = min(color.saturation, otherColor.saturation) + (abs(color.saturation - otherColor.saturation) * percent)
57 | let brightness = min(color.brightness, otherColor.brightness) + (abs(color.brightness - otherColor.brightness) * percent)
58 | return HSBColor(hue: hue, saturation: saturation, brightness: brightness)
59 | }
60 |
61 | static func ==(lhs: HSBColor, rhs: HSBColor) -> Bool {
62 | return lhs.hue == rhs.hue &&
63 | lhs.saturation == rhs.saturation &&
64 | lhs.brightness == rhs.brightness
65 | }
66 | }
67 |
68 | /// :nodoc:
69 | internal extension UIColor {
70 | /// A convenience initializer to create a `UIColor` from an `HSBColor`.
71 | convenience init(hsbColor: HSBColor) {
72 | self.init(hue: hsbColor.hue, saturation: hsbColor.saturation, brightness: hsbColor.brightness, alpha: 1)
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/ColorSlider/ColorSlider.xcodeproj/xcshareddata/xcschemes/ColorSlider.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 |
--------------------------------------------------------------------------------
/Sources/Internal/Gradient.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Gradient.swift
3 | //
4 | // Created by Sachin Patel on 10/19/17.
5 | //
6 | // The MIT License (MIT)
7 | //
8 | // Copyright (c) 2017-Present Sachin Patel (http://gizmosachin.com/)
9 | //
10 | // Permission is hereby granted, free of charge, to any person obtaining a copy
11 | // of this software and associated documentation files (the "Software"), to deal
12 | // in the Software without restriction, including without limitation the rights
13 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | // copies of the Software, and to permit persons to whom the Software is
15 | // furnished to do so, subject to the following conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be included in all
18 | // copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | // SOFTWARE.
27 |
28 | import UIKit
29 |
30 | /// :nodoc:
31 | /// A gradient value type.
32 | internal struct Gradient {
33 | public let colors: [HSBColor]
34 | public let locations: [CGFloat]
35 |
36 | init(colors: [HSBColor], locations: [CGFloat]) {
37 | assert(locations.count >= 2, "There must be at least two locations to create a gradient.")
38 | assert(colors.count == locations.count, "The number of colors and number of locations must be equal.")
39 |
40 | locations.forEach { (location) in
41 | assert(location >= 0.0 && location <= 1.0, "Location must be between 0 and 1.")
42 | }
43 |
44 | // Create a sequence of the pairings, sorted ascending by location
45 | let pairs = zip(colors, locations).sorted { $0.1 < $1.1 }
46 |
47 | // Assign the internal colors and locations from the pairs
48 | self.colors = pairs.map { $0.0 }
49 | self.locations = pairs.map { $0.1 }
50 | }
51 |
52 | func color(at percent: CGFloat) -> HSBColor {
53 | assert(percent >= 0.0 && percent <= 1.0, "Percent must be between 0 and 1.")
54 |
55 | // Find the indices that contain the closest values below and above `percent`
56 | guard let maxIndex = locations.firstIndex (where: { (location) -> Bool in
57 | return location >= percent
58 | }) else { return colors[locations.endIndex] }
59 | guard maxIndex > locations.startIndex else { return colors[maxIndex] }
60 | let minIndex = locations.index(before: maxIndex)
61 |
62 | // Get the two locations
63 | let minLocation = locations[minIndex]
64 | let maxLocation = locations[maxIndex]
65 |
66 | // Get the two colors
67 | let leftColor = colors[minIndex]
68 | let rightColor = colors[maxIndex]
69 |
70 | // Calculate the percentage between the two colors that we want to find
71 | var scaledPercentage = (percent - minLocation) / (maxLocation - minLocation)
72 | if leftColor.hue > rightColor.hue && !leftColor.isGrayscale {
73 | scaledPercentage = 1 - scaledPercentage
74 | }
75 |
76 | return HSBColor.between(color: leftColor, and: rightColor, percent: scaledPercentage)
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Sources/PreviewView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PreviewView.swift
3 | //
4 | // Created by Sachin Patel on 5/27/17.
5 | //
6 | // The MIT License (MIT)
7 | //
8 | // Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
9 | //
10 | // Permission is hereby granted, free of charge, to any person obtaining a copy
11 | // of this software and associated documentation files (the "Software"), to deal
12 | // in the Software without restriction, including without limitation the rights
13 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | // copies of the Software, and to permit persons to whom the Software is
15 | // furnished to do so, subject to the following conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be included in all
18 | // copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | // SOFTWARE.
27 |
28 | import UIKit
29 |
30 | public typealias PreviewView = UIView & ColorSliderPreviewing
31 |
32 | /// The display state of a preview view.
33 | public enum PreviewState {
34 | /// The color is not being changed and the preview view is centered at the last modified point.
35 | case inactive
36 |
37 | /// The color is still being changed, but the preview view center is fixed.
38 | /// This occurs when a touch begins inside the slider but continues outside of it.
39 | /// In this case, the color is actively being modified, but the preview remains fixed at
40 | /// the same position that it was when the touch moved outside of the slider.
41 | case activeFixed
42 |
43 | /// The color is being actively changed and the preview view center will be updated to match the current color.
44 | case active
45 | }
46 |
47 | /// A protocol defining callback methods for a `ColorSlider` preview view.
48 | ///
49 | /// To create a custom preview view, create a `UIView` subclass and implement `ColorSliderPreviewing`.
50 | /// Then, create an instance of your custom preview view and pass it to the `ColorSlider` initializer.
51 | /// As a user drags their finger, `ColorSlider` will automatically set your preview view's `center`
52 | /// to the point closest to the touch, centered along the axis perpendicular to the `ColorSlider`'s orientation.
53 | ///
54 | /// If `autoresizesSubviews` is `true` (the default value on all `UIView`s) on your `ColorSlider`, your preview view
55 | /// will also be automatically resized when its `center` point is being set. To disable resizing your preview, set
56 | /// the `autoresizesSubviews` property on your `ColorSlider` to `false`.
57 |
58 | public protocol ColorSliderPreviewing {
59 | /// Called when the color of the slider changes, so the preview can respond correctly.
60 | /// - parameter color: The newly selected color.
61 | func colorChanged(to color: UIColor)
62 |
63 | /// Called when the preview changes state and should update its appearance appropriately.
64 | /// Since `ColorSlider` sets the `center` of your preview automatically, you should use your
65 | /// view's `transform` to adjust or animate most changes. See `DefaultPreviewView` for an example.
66 | /// - parameter state: The new state of the preview view.
67 | func transition(to state: PreviewState)
68 | }
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ---
6 |
7 | ColorSlider is an iOS color picker with live preview written in [Swift](https://developer.apple.com/swift/).
8 |
9 | [](https://travis-ci.org/gizmosachin/ColorSlider)  [](https://developer.apple.com/swift) [](LICENSE)
10 |
11 | | | Features |
12 | | :-------: | :--------------------------------------- |
13 | | :ghost: | "[Snapchat](https://snapchat.com)-style" color picker |
14 | | :rainbow: | Extensible live preview |
15 | | :art: | Customizable appearance |
16 | | :cyclone: | Vertical and horizontal support |
17 | | :musical_keyboard: | Black and white colors included |
18 | | :books: | Fully [documented](https://gizmosachin.github.io/ColorSlider) |
19 | | :baby_chick: | [Swift 5](https://developer.apple.com/swift/) |
20 |
21 | ## Usage
22 |
23 | Create and add a ColorSlider to your view:
24 |
25 | ``` Swift
26 | let colorSlider = ColorSlider(orientation: .vertical, previewSide: .left)
27 | colorSlider.frame = CGRect(x: 0, y: 0, width: 12, height: 150)
28 | view.addSubview(colorSlider)
29 | ```
30 |
31 | Respond to changes in color using `UIControlEvents`:
32 |
33 | ``` Swift
34 | colorSlider.addTarget(self, action: #selector(changedColor(_:)), forControlEvents: .valueChanged)
35 |
36 | func changedColor(_ slider: ColorSlider) {
37 | var color = slider.color
38 | // ...
39 | }
40 | ```
41 |
42 | Customize appearance attributes:
43 |
44 | ``` Swift
45 | // Add a border
46 | colorSlider.gradientView.layer.borderWidth = 2.0
47 | colorSlider.gradientView.layer.borderColor = UIColor.white.cgColor
48 |
49 | // Disable rounded corners
50 | colorSlider.gradientView.automaticallyAdjustsCornerRadius = false
51 | ```
52 |
53 | ### Preview
54 |
55 | `ColorSlider` has a live preview that tracks touches along it. You can customize it:
56 |
57 | ``` Swift
58 | let previewView = ColorSlider.DefaultPreviewView()
59 | previewView.side = .right
60 | previewView.animationDuration = 0.2
61 | previewView.offsetAmount = 50
62 |
63 | let colorSlider = ColorSlider(orientation: .vertical, previewView: previewView)
64 | ```
65 |
66 | Create your own live preview by subclassing `DefaultPreviewView` or implementing `ColorSliderPreviewing` in your `UIView` subclass.
67 | Then, just pass your preview instance to the initializer:
68 | ``` Swift
69 | let customPreviewView = MyCustomPreviewView()
70 | let colorSlider = ColorSlider(orientation: .vertical, previewView: customPreviewView)
71 | ```
72 | ColorSlider will automatically update your view's `center` as touches move on the slider.
73 | By default, it'll also resize your preview automatically. Set `colorSlider.autoresizesSubviews` to `false` to disable autoresizing.
74 |
75 | To disable the preview, simply pass `nil` to ColorSlider's initializer:
76 | ``` Swift
77 | let colorSlider = ColorSlider(orientation: .vertical, previewView: nil)
78 | ```
79 |
80 | See the [documentation](https://gizmosachin.github.io/ColorSlider) for more details on custom previews.
81 |
82 | ### Documentation
83 |
84 | ColorSlider is fully documented [here](https://gizmosachin.github.io/ColorSlider).
85 |
86 | ## Installation
87 |
88 | ### [CocoaPods](https://cocoapods.org/)
89 |
90 | ``` ruby
91 | platform :ios, '9.0'
92 | pod 'ColorSlider', '~> 4.4'
93 | ```
94 |
95 | ### [Carthage](https://github.com/Carthage/Carthage)
96 |
97 | ``` ruby
98 | github "gizmosachin/ColorSlider" >= 4.4
99 | ```
100 |
101 | ## Version Compatibility
102 |
103 | | Swift Version | ColorSlider Version |
104 | | ------------- | ------------------- |
105 | | 5.0 | master |
106 | | 4.2 | 4.3 |
107 |
108 | ## Demo
109 |
110 | Please see the `Demo` directory for a basic iOS project that uses `ColorSlider`.
111 |
112 | ## Contributing
113 |
114 | ColorSlider is a community - contributions and discussions are welcome!
115 |
116 | Please read the [contributing guidelines](CONTRIBUTING.md) prior to submitting a Pull Request.
117 |
118 | ## License
119 |
120 | ColorSlider is available under the MIT license, see the [LICENSE](LICENSE) file for more information.
121 |
--------------------------------------------------------------------------------
/Demo/ColorSliderDemo/DemoView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DemoView.swift
3 | // ColorSliderDemo
4 | //
5 | // Created by Sachin Patel on 9/7/17.
6 | //
7 | // The MIT License (MIT)
8 | //
9 | // Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy
12 | // of this software and associated documentation files (the "Software"), to deal
13 | // in the Software without restriction, including without limitation the rights
14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | // copies of the Software, and to permit persons to whom the Software is
16 | // furnished to do so, subject to the following conditions:
17 | //
18 | // The above copyright notice and this permission notice shall be included in all
19 | // copies or substantial portions of the Software.
20 | //
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 | // SOFTWARE.
28 |
29 | import UIKit
30 | import SpriteKit
31 |
32 | class DemoView: UIView {
33 | private let colorSlider: ColorSlider
34 | private let label: UILabel
35 |
36 | private var particleEmitter: SKEmitterNode?
37 |
38 | override init(frame: CGRect) {
39 | // Set up ColorSlider and label
40 | colorSlider = ColorSlider(orientation: .vertical, previewSide: .left)
41 | label = UILabel()
42 |
43 | super.init(frame: frame)
44 |
45 | backgroundColor = .black
46 |
47 | // Only add particle emitter on device (lags on iOS simulator).
48 | #if !(arch(i386) || arch(x86_64))
49 | setupParticleEmitter()
50 | #endif
51 |
52 | // Set up and add the label
53 | label.textColor = .white
54 | label.text = "ColorSlider"
55 | label.textAlignment = .center
56 | label.font = UIFont.systemFont(ofSize: 100, weight: .bold)
57 | label.adjustsFontSizeToFitWidth = true
58 | addSubview(label)
59 |
60 | // Observe ColorSlider events
61 | colorSlider.addTarget(self, action: #selector(changedColor(slider:)), for: .valueChanged)
62 | addSubview(colorSlider)
63 |
64 | setupConstraints()
65 |
66 | }
67 |
68 | required init?(coder aDecoder: NSCoder) {
69 | fatalError("init(coder:) has not been implemented")
70 | }
71 |
72 | // Set up the particle emitter in the background.
73 | // This is totally unnecessary for ColorSlider but makes for a fun demo.
74 | func setupParticleEmitter() {
75 | let particleView = SKView()
76 | guard let emitter = SKEmitterNode(fileNamed: "Spark.sks") else { return }
77 |
78 | emitter.particleColorBlendFactor = 1
79 | emitter.particleColorSequence = nil
80 | emitter.particleColor = .red
81 | addSubview(particleView)
82 |
83 | let scene = SKScene(size: UIScreen.main.bounds.size)
84 | scene.scaleMode = .aspectFill
85 | scene.backgroundColor = .clear
86 |
87 | emitter.position = CGPoint(x: UIScreen.main.bounds.midX, y: UIScreen.main.bounds.height * 0.6)
88 | scene.addChild(emitter)
89 | particleView.presentScene(scene)
90 |
91 | particleView.translatesAutoresizingMaskIntoConstraints = false
92 | NSLayoutConstraint.activate([
93 | particleView.leftAnchor.constraint(equalTo: leftAnchor),
94 | particleView.rightAnchor.constraint(equalTo: rightAnchor),
95 | particleView.topAnchor.constraint(equalTo: topAnchor),
96 | particleView.bottomAnchor.constraint(equalTo: bottomAnchor),
97 | ])
98 |
99 | particleEmitter = emitter
100 | }
101 |
102 | // Set up view constraints.
103 | func setupConstraints() {
104 | let inset = CGFloat(30)
105 | let colorSliderHeight = CGFloat(150)
106 | label.translatesAutoresizingMaskIntoConstraints = false
107 | colorSlider.translatesAutoresizingMaskIntoConstraints = false
108 | NSLayoutConstraint.activate([
109 | colorSlider.centerXAnchor.constraint(equalTo: centerXAnchor),
110 | colorSlider.bottomAnchor.constraint(equalTo: centerYAnchor),
111 | colorSlider.widthAnchor.constraint(equalToConstant: 15),
112 | colorSlider.heightAnchor.constraint(equalToConstant: colorSliderHeight),
113 |
114 | label.leftAnchor.constraint(equalTo: leftAnchor, constant: inset),
115 | label.rightAnchor.constraint(equalTo: rightAnchor, constant: -inset),
116 | label.topAnchor.constraint(equalTo: colorSlider.bottomAnchor, constant: inset),
117 | label.heightAnchor.constraint(equalToConstant: 100),
118 | ])
119 | }
120 |
121 | // Observe ColorSlider .valueChanged events.
122 | @objc func changedColor(slider: ColorSlider) {
123 | label.textColor = slider.color
124 | particleEmitter?.particleColor = slider.color
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/docs/css/highlight.css:
--------------------------------------------------------------------------------
1 | /* Credit to https://gist.github.com/wataru420/2048287 */
2 | .highlight {
3 | /* Comment */
4 | /* Error */
5 | /* Keyword */
6 | /* Operator */
7 | /* Comment.Multiline */
8 | /* Comment.Preproc */
9 | /* Comment.Single */
10 | /* Comment.Special */
11 | /* Generic.Deleted */
12 | /* Generic.Deleted.Specific */
13 | /* Generic.Emph */
14 | /* Generic.Error */
15 | /* Generic.Heading */
16 | /* Generic.Inserted */
17 | /* Generic.Inserted.Specific */
18 | /* Generic.Output */
19 | /* Generic.Prompt */
20 | /* Generic.Strong */
21 | /* Generic.Subheading */
22 | /* Generic.Traceback */
23 | /* Keyword.Constant */
24 | /* Keyword.Declaration */
25 | /* Keyword.Pseudo */
26 | /* Keyword.Reserved */
27 | /* Keyword.Type */
28 | /* Literal.Number */
29 | /* Literal.String */
30 | /* Name.Attribute */
31 | /* Name.Builtin */
32 | /* Name.Class */
33 | /* Name.Constant */
34 | /* Name.Entity */
35 | /* Name.Exception */
36 | /* Name.Function */
37 | /* Name.Namespace */
38 | /* Name.Tag */
39 | /* Name.Variable */
40 | /* Operator.Word */
41 | /* Text.Whitespace */
42 | /* Literal.Number.Float */
43 | /* Literal.Number.Hex */
44 | /* Literal.Number.Integer */
45 | /* Literal.Number.Oct */
46 | /* Literal.String.Backtick */
47 | /* Literal.String.Char */
48 | /* Literal.String.Doc */
49 | /* Literal.String.Double */
50 | /* Literal.String.Escape */
51 | /* Literal.String.Heredoc */
52 | /* Literal.String.Interpol */
53 | /* Literal.String.Other */
54 | /* Literal.String.Regex */
55 | /* Literal.String.Single */
56 | /* Literal.String.Symbol */
57 | /* Name.Builtin.Pseudo */
58 | /* Name.Variable.Class */
59 | /* Name.Variable.Global */
60 | /* Name.Variable.Instance */
61 | /* Literal.Number.Integer.Long */ }
62 | .highlight .c {
63 | color: #999988;
64 | font-style: italic; }
65 | .highlight .err {
66 | color: #a61717;
67 | background-color: #e3d2d2; }
68 | .highlight .k {
69 | color: #000000;
70 | font-weight: bold; }
71 | .highlight .o {
72 | color: #000000;
73 | font-weight: bold; }
74 | .highlight .cm {
75 | color: #999988;
76 | font-style: italic; }
77 | .highlight .cp {
78 | color: #999999;
79 | font-weight: bold; }
80 | .highlight .c1 {
81 | color: #999988;
82 | font-style: italic; }
83 | .highlight .cs {
84 | color: #999999;
85 | font-weight: bold;
86 | font-style: italic; }
87 | .highlight .gd {
88 | color: #000000;
89 | background-color: #ffdddd; }
90 | .highlight .gd .x {
91 | color: #000000;
92 | background-color: #ffaaaa; }
93 | .highlight .ge {
94 | color: #000000;
95 | font-style: italic; }
96 | .highlight .gr {
97 | color: #aa0000; }
98 | .highlight .gh {
99 | color: #999999; }
100 | .highlight .gi {
101 | color: #000000;
102 | background-color: #ddffdd; }
103 | .highlight .gi .x {
104 | color: #000000;
105 | background-color: #aaffaa; }
106 | .highlight .go {
107 | color: #888888; }
108 | .highlight .gp {
109 | color: #555555; }
110 | .highlight .gs {
111 | font-weight: bold; }
112 | .highlight .gu {
113 | color: #aaaaaa; }
114 | .highlight .gt {
115 | color: #aa0000; }
116 | .highlight .kc {
117 | color: #000000;
118 | font-weight: bold; }
119 | .highlight .kd {
120 | color: #000000;
121 | font-weight: bold; }
122 | .highlight .kp {
123 | color: #000000;
124 | font-weight: bold; }
125 | .highlight .kr {
126 | color: #000000;
127 | font-weight: bold; }
128 | .highlight .kt {
129 | color: #445588; }
130 | .highlight .m {
131 | color: #009999; }
132 | .highlight .s {
133 | color: #d14; }
134 | .highlight .na {
135 | color: #008080; }
136 | .highlight .nb {
137 | color: #0086B3; }
138 | .highlight .nc {
139 | color: #445588;
140 | font-weight: bold; }
141 | .highlight .no {
142 | color: #008080; }
143 | .highlight .ni {
144 | color: #800080; }
145 | .highlight .ne {
146 | color: #990000;
147 | font-weight: bold; }
148 | .highlight .nf {
149 | color: #990000; }
150 | .highlight .nn {
151 | color: #555555; }
152 | .highlight .nt {
153 | color: #000080; }
154 | .highlight .nv {
155 | color: #008080; }
156 | .highlight .ow {
157 | color: #000000;
158 | font-weight: bold; }
159 | .highlight .w {
160 | color: #bbbbbb; }
161 | .highlight .mf {
162 | color: #009999; }
163 | .highlight .mh {
164 | color: #009999; }
165 | .highlight .mi {
166 | color: #009999; }
167 | .highlight .mo {
168 | color: #009999; }
169 | .highlight .sb {
170 | color: #d14; }
171 | .highlight .sc {
172 | color: #d14; }
173 | .highlight .sd {
174 | color: #d14; }
175 | .highlight .s2 {
176 | color: #d14; }
177 | .highlight .se {
178 | color: #d14; }
179 | .highlight .sh {
180 | color: #d14; }
181 | .highlight .si {
182 | color: #d14; }
183 | .highlight .sx {
184 | color: #d14; }
185 | .highlight .sr {
186 | color: #009926; }
187 | .highlight .s1 {
188 | color: #d14; }
189 | .highlight .ss {
190 | color: #990073; }
191 | .highlight .bp {
192 | color: #999999; }
193 | .highlight .vc {
194 | color: #008080; }
195 | .highlight .vg {
196 | color: #008080; }
197 | .highlight .vi {
198 | color: #008080; }
199 | .highlight .il {
200 | color: #009999; }
201 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/css/highlight.css:
--------------------------------------------------------------------------------
1 | /* Credit to https://gist.github.com/wataru420/2048287 */
2 | .highlight {
3 | /* Comment */
4 | /* Error */
5 | /* Keyword */
6 | /* Operator */
7 | /* Comment.Multiline */
8 | /* Comment.Preproc */
9 | /* Comment.Single */
10 | /* Comment.Special */
11 | /* Generic.Deleted */
12 | /* Generic.Deleted.Specific */
13 | /* Generic.Emph */
14 | /* Generic.Error */
15 | /* Generic.Heading */
16 | /* Generic.Inserted */
17 | /* Generic.Inserted.Specific */
18 | /* Generic.Output */
19 | /* Generic.Prompt */
20 | /* Generic.Strong */
21 | /* Generic.Subheading */
22 | /* Generic.Traceback */
23 | /* Keyword.Constant */
24 | /* Keyword.Declaration */
25 | /* Keyword.Pseudo */
26 | /* Keyword.Reserved */
27 | /* Keyword.Type */
28 | /* Literal.Number */
29 | /* Literal.String */
30 | /* Name.Attribute */
31 | /* Name.Builtin */
32 | /* Name.Class */
33 | /* Name.Constant */
34 | /* Name.Entity */
35 | /* Name.Exception */
36 | /* Name.Function */
37 | /* Name.Namespace */
38 | /* Name.Tag */
39 | /* Name.Variable */
40 | /* Operator.Word */
41 | /* Text.Whitespace */
42 | /* Literal.Number.Float */
43 | /* Literal.Number.Hex */
44 | /* Literal.Number.Integer */
45 | /* Literal.Number.Oct */
46 | /* Literal.String.Backtick */
47 | /* Literal.String.Char */
48 | /* Literal.String.Doc */
49 | /* Literal.String.Double */
50 | /* Literal.String.Escape */
51 | /* Literal.String.Heredoc */
52 | /* Literal.String.Interpol */
53 | /* Literal.String.Other */
54 | /* Literal.String.Regex */
55 | /* Literal.String.Single */
56 | /* Literal.String.Symbol */
57 | /* Name.Builtin.Pseudo */
58 | /* Name.Variable.Class */
59 | /* Name.Variable.Global */
60 | /* Name.Variable.Instance */
61 | /* Literal.Number.Integer.Long */ }
62 | .highlight .c {
63 | color: #999988;
64 | font-style: italic; }
65 | .highlight .err {
66 | color: #a61717;
67 | background-color: #e3d2d2; }
68 | .highlight .k {
69 | color: #000000;
70 | font-weight: bold; }
71 | .highlight .o {
72 | color: #000000;
73 | font-weight: bold; }
74 | .highlight .cm {
75 | color: #999988;
76 | font-style: italic; }
77 | .highlight .cp {
78 | color: #999999;
79 | font-weight: bold; }
80 | .highlight .c1 {
81 | color: #999988;
82 | font-style: italic; }
83 | .highlight .cs {
84 | color: #999999;
85 | font-weight: bold;
86 | font-style: italic; }
87 | .highlight .gd {
88 | color: #000000;
89 | background-color: #ffdddd; }
90 | .highlight .gd .x {
91 | color: #000000;
92 | background-color: #ffaaaa; }
93 | .highlight .ge {
94 | color: #000000;
95 | font-style: italic; }
96 | .highlight .gr {
97 | color: #aa0000; }
98 | .highlight .gh {
99 | color: #999999; }
100 | .highlight .gi {
101 | color: #000000;
102 | background-color: #ddffdd; }
103 | .highlight .gi .x {
104 | color: #000000;
105 | background-color: #aaffaa; }
106 | .highlight .go {
107 | color: #888888; }
108 | .highlight .gp {
109 | color: #555555; }
110 | .highlight .gs {
111 | font-weight: bold; }
112 | .highlight .gu {
113 | color: #aaaaaa; }
114 | .highlight .gt {
115 | color: #aa0000; }
116 | .highlight .kc {
117 | color: #000000;
118 | font-weight: bold; }
119 | .highlight .kd {
120 | color: #000000;
121 | font-weight: bold; }
122 | .highlight .kp {
123 | color: #000000;
124 | font-weight: bold; }
125 | .highlight .kr {
126 | color: #000000;
127 | font-weight: bold; }
128 | .highlight .kt {
129 | color: #445588; }
130 | .highlight .m {
131 | color: #009999; }
132 | .highlight .s {
133 | color: #d14; }
134 | .highlight .na {
135 | color: #008080; }
136 | .highlight .nb {
137 | color: #0086B3; }
138 | .highlight .nc {
139 | color: #445588;
140 | font-weight: bold; }
141 | .highlight .no {
142 | color: #008080; }
143 | .highlight .ni {
144 | color: #800080; }
145 | .highlight .ne {
146 | color: #990000;
147 | font-weight: bold; }
148 | .highlight .nf {
149 | color: #990000; }
150 | .highlight .nn {
151 | color: #555555; }
152 | .highlight .nt {
153 | color: #000080; }
154 | .highlight .nv {
155 | color: #008080; }
156 | .highlight .ow {
157 | color: #000000;
158 | font-weight: bold; }
159 | .highlight .w {
160 | color: #bbbbbb; }
161 | .highlight .mf {
162 | color: #009999; }
163 | .highlight .mh {
164 | color: #009999; }
165 | .highlight .mi {
166 | color: #009999; }
167 | .highlight .mo {
168 | color: #009999; }
169 | .highlight .sb {
170 | color: #d14; }
171 | .highlight .sc {
172 | color: #d14; }
173 | .highlight .sd {
174 | color: #d14; }
175 | .highlight .s2 {
176 | color: #d14; }
177 | .highlight .se {
178 | color: #d14; }
179 | .highlight .sh {
180 | color: #d14; }
181 | .highlight .si {
182 | color: #d14; }
183 | .highlight .sx {
184 | color: #d14; }
185 | .highlight .sr {
186 | color: #009926; }
187 | .highlight .s1 {
188 | color: #d14; }
189 | .highlight .ss {
190 | color: #990073; }
191 | .highlight .bp {
192 | color: #999999; }
193 | .highlight .vc {
194 | color: #008080; }
195 | .highlight .vg {
196 | color: #008080; }
197 | .highlight .vi {
198 | color: #008080; }
199 | .highlight .il {
200 | color: #009999; }
201 |
--------------------------------------------------------------------------------
/docs/Classes/ColorSlider/Orientation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Orientation Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | Orientation Enum Reference
27 |
28 |
29 |
30 |
45 |
46 |
47 |
48 | Orientation
49 |
50 |
51 |
public enum Orientation
52 |
53 |
54 |
55 | The display orientation of the ColorSlider .
56 |
57 |
58 |
59 |
60 |
61 |
62 |
69 |
70 |
71 |
72 |
73 |
77 |
78 |
Declaration
79 |
80 |
Swift
81 |
case vertical
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
100 |
101 |
102 |
103 |
104 |
108 |
109 |
Declaration
110 |
111 |
Swift
112 |
case horizontal
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/Classes/ColorSlider/Orientation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Orientation Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | Orientation Enum Reference
27 |
28 |
29 |
30 |
45 |
46 |
47 |
48 | Orientation
49 |
50 |
51 |
public enum Orientation
52 |
53 |
54 |
55 | The display orientation of the ColorSlider .
56 |
57 |
58 |
59 |
60 |
61 |
62 |
69 |
70 |
71 |
72 |
73 |
77 |
78 |
Declaration
79 |
80 |
Swift
81 |
case vertical
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
100 |
101 |
102 |
103 |
104 |
108 |
109 |
Declaration
110 |
111 |
Swift
112 |
case horizontal
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/docs/Protocols.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Protocols Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
22 |
23 | ColorSlider Reference
24 |
25 | Protocols Reference
26 |
27 |
28 |
29 |
69 |
70 |
71 |
72 | Protocols
73 | The following protocols are available globally.
74 |
75 |
76 |
77 |
78 |
79 |
80 |
87 |
88 |
89 |
90 |
91 |
92 |
A protocol defining callback methods for a ColorSlider preview view.
93 |
94 |
To create a custom preview view, create a UIView subclass and implement ColorSliderPreviewing.
95 | Then, create an instance of your custom preview view and pass it to the ColorSlider initializer.
96 | As a user drags their finger, ColorSlider will automatically set your preview view’s center
97 | to the point closest to the touch, centered along the axis perpendicular to the ColorSlider ‘s orientation.
98 |
99 |
If autoresizesSubviews is true (the default value on all UIViews) on your ColorSlider , your preview view
100 | will also be automatically resized when its center point is being set. To disable resizing your preview, set
101 | the autoresizesSubviews property on your ColorSlider to false.
102 |
103 |
See more
104 |
105 |
106 |
Declaration
107 |
108 |
Swift
109 |
public protocol ColorSliderPreviewing
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/Protocols.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Protocols Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
22 |
23 | ColorSlider Reference
24 |
25 | Protocols Reference
26 |
27 |
28 |
29 |
69 |
70 |
71 |
72 | Protocols
73 | The following protocols are available globally.
74 |
75 |
76 |
77 |
78 |
79 |
80 |
87 |
88 |
89 |
90 |
91 |
92 |
A protocol defining callback methods for a ColorSlider preview view.
93 |
94 |
To create a custom preview view, create a UIView subclass and implement ColorSliderPreviewing.
95 | Then, create an instance of your custom preview view and pass it to the ColorSlider initializer.
96 | As a user drags their finger, ColorSlider will automatically set your preview view’s center
97 | to the point closest to the touch, centered along the axis perpendicular to the ColorSlider ‘s orientation.
98 |
99 |
If autoresizesSubviews is true (the default value on all UIViews) on your ColorSlider , your preview view
100 | will also be automatically resized when its center point is being set. To disable resizing your preview, set
101 | the autoresizesSubviews property on your ColorSlider to false.
102 |
103 |
See more
104 |
105 |
106 |
Declaration
107 |
108 |
Swift
109 |
public protocol ColorSliderPreviewing
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/docs/Enums.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Enums Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
22 |
23 | ColorSlider Reference
24 |
25 | Enums Reference
26 |
27 |
28 |
29 |
69 |
70 |
71 |
72 | Enums
73 | The following enums are available globally.
74 |
75 |
76 |
77 |
78 |
79 |
80 |
87 |
88 |
89 |
90 |
91 |
96 |
97 |
Declaration
98 |
99 |
Swift
100 |
public enum Orientation
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
119 |
120 |
121 |
122 |
123 |
124 |
The display state of a preview view.
125 |
126 |
See more
127 |
128 |
129 |
Declaration
130 |
131 |
Swift
132 |
public enum PreviewState
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/Enums.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Enums Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
22 |
23 | ColorSlider Reference
24 |
25 | Enums Reference
26 |
27 |
28 |
29 |
69 |
70 |
71 |
72 | Enums
73 | The following enums are available globally.
74 |
75 |
76 |
77 |
78 |
79 |
80 |
87 |
88 |
89 |
90 |
91 |
96 |
97 |
Declaration
98 |
99 |
Swift
100 |
public enum Orientation
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
119 |
120 |
121 |
122 |
123 |
124 |
The display state of a preview view.
125 |
126 |
See more
127 |
128 |
129 |
Declaration
130 |
131 |
Swift
132 |
public enum PreviewState
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/docs/Enums/Orientation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Orientation Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | Orientation Enum Reference
27 |
28 |
29 |
30 |
70 |
71 |
72 |
73 | Orientation
74 |
75 |
76 |
public enum Orientation
77 |
78 |
79 |
80 | The orientation in which the ColorSlider is drawn.
81 |
82 |
83 |
84 |
85 |
86 |
87 |
94 |
95 |
96 |
97 |
98 |
99 |
The horizontal orientation.
100 |
101 |
102 |
103 |
Declaration
104 |
105 |
Swift
106 |
case horizontal
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | vertical
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
The vertical orientation.
131 |
132 |
133 |
134 |
Declaration
135 |
136 |
Swift
137 |
case vertical
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/Enums/Orientation.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Orientation Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | Orientation Enum Reference
27 |
28 |
29 |
30 |
70 |
71 |
72 |
73 | Orientation
74 |
75 |
76 |
public enum Orientation
77 |
78 |
79 |
80 | The orientation in which the ColorSlider is drawn.
81 |
82 |
83 |
84 |
85 |
86 |
87 |
94 |
95 |
96 |
97 |
98 |
99 |
The horizontal orientation.
100 |
101 |
102 |
103 |
Declaration
104 |
105 |
Swift
106 |
case horizontal
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | vertical
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
The vertical orientation.
131 |
132 |
133 |
134 |
Declaration
135 |
136 |
Swift
137 |
case vertical
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/docs/css/jazzy.css:
--------------------------------------------------------------------------------
1 | html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td {
2 | background: transparent;
3 | border: 0;
4 | margin: 0;
5 | outline: 0;
6 | padding: 0;
7 | vertical-align: baseline; }
8 |
9 | body {
10 | background-color: #f2f2f2;
11 | font-family: Helvetica, freesans, Arial, sans-serif;
12 | font-size: 14px;
13 | -webkit-font-smoothing: subpixel-antialiased;
14 | word-wrap: break-word; }
15 |
16 | h1, h2, h3 {
17 | margin-top: 0.8em;
18 | margin-bottom: 0.3em;
19 | font-weight: 100;
20 | color: black; }
21 |
22 | h1 {
23 | font-size: 2.5em; }
24 |
25 | h2 {
26 | font-size: 2em;
27 | border-bottom: 1px solid #e2e2e2; }
28 |
29 | h4 {
30 | font-size: 13px;
31 | line-height: 1.5;
32 | margin-top: 21px; }
33 |
34 | h5 {
35 | font-size: 1.1em; }
36 |
37 | h6 {
38 | font-size: 1.1em;
39 | color: #777; }
40 |
41 | .section-name {
42 | color: gray;
43 | display: block;
44 | font-family: Helvetica;
45 | font-size: 22px;
46 | font-weight: 100;
47 | margin-bottom: 15px; }
48 |
49 | pre, code {
50 | font: 0.95em Menlo, monospace;
51 | color: #777;
52 | word-wrap: normal; }
53 |
54 | p code, li code {
55 | background-color: #eee;
56 | padding: 2px 4px;
57 | border-radius: 4px; }
58 |
59 | a {
60 | color: #0088cc;
61 | text-decoration: none; }
62 |
63 | ul {
64 | padding-left: 15px; }
65 |
66 | li {
67 | line-height: 1.8em; }
68 |
69 | img {
70 | max-width: 100%; }
71 |
72 | blockquote {
73 | margin-left: 0;
74 | padding: 0 10px;
75 | border-left: 4px solid #ccc; }
76 |
77 | .content-wrapper {
78 | margin: 0 auto;
79 | width: 980px; }
80 |
81 | header {
82 | font-size: 0.85em;
83 | line-height: 26px;
84 | background-color: #414141;
85 | position: fixed;
86 | width: 100%;
87 | z-index: 1; }
88 | header img {
89 | padding-right: 6px;
90 | vertical-align: -4px;
91 | height: 16px; }
92 | header a {
93 | color: #fff; }
94 | header p {
95 | float: left;
96 | color: #999; }
97 | header .header-right {
98 | float: right;
99 | margin-left: 16px; }
100 |
101 | #breadcrumbs {
102 | background-color: #f2f2f2;
103 | height: 27px;
104 | padding-top: 17px;
105 | position: fixed;
106 | width: 100%;
107 | z-index: 1;
108 | margin-top: 26px; }
109 | #breadcrumbs #carat {
110 | height: 10px;
111 | margin: 0 5px; }
112 |
113 | .sidebar {
114 | background-color: #f9f9f9;
115 | border: 1px solid #e2e2e2;
116 | overflow-y: auto;
117 | overflow-x: hidden;
118 | position: fixed;
119 | top: 70px;
120 | bottom: 0;
121 | width: 230px;
122 | word-wrap: normal; }
123 |
124 | .nav-groups {
125 | list-style-type: none;
126 | background: #fff;
127 | padding-left: 0; }
128 |
129 | .nav-group-name {
130 | border-bottom: 1px solid #e2e2e2;
131 | font-size: 1.1em;
132 | font-weight: 100;
133 | padding: 15px 0 15px 20px; }
134 | .nav-group-name > a {
135 | color: #333; }
136 |
137 | .nav-group-tasks {
138 | margin-top: 5px; }
139 |
140 | .nav-group-task {
141 | font-size: 0.9em;
142 | list-style-type: none;
143 | white-space: nowrap; }
144 | .nav-group-task a {
145 | color: #888; }
146 |
147 | .main-content {
148 | background-color: #fff;
149 | border: 1px solid #e2e2e2;
150 | margin-left: 246px;
151 | position: absolute;
152 | overflow: hidden;
153 | padding-bottom: 60px;
154 | top: 70px;
155 | width: 734px; }
156 | .main-content p, .main-content a, .main-content code, .main-content em, .main-content ul, .main-content table, .main-content blockquote {
157 | margin-bottom: 1em; }
158 | .main-content p {
159 | line-height: 1.8em; }
160 | .main-content section .section:first-child {
161 | margin-top: 0;
162 | padding-top: 0; }
163 | .main-content section .task-group-section .task-group:first-of-type {
164 | padding-top: 10px; }
165 | .main-content section .task-group-section .task-group:first-of-type .section-name {
166 | padding-top: 15px; }
167 | .main-content section .heading:before {
168 | content: "";
169 | display: block;
170 | padding-top: 70px;
171 | margin: -70px 0 0; }
172 |
173 | .section {
174 | padding: 0 25px; }
175 |
176 | .highlight {
177 | background-color: #eee;
178 | padding: 10px 12px;
179 | border: 1px solid #e2e2e2;
180 | border-radius: 4px;
181 | overflow-x: auto; }
182 |
183 | .declaration .highlight {
184 | overflow-x: initial;
185 | padding: 0 40px 40px 0;
186 | margin-bottom: -25px;
187 | background-color: transparent;
188 | border: none; }
189 |
190 | .section-name {
191 | margin: 0;
192 | margin-left: 18px; }
193 |
194 | .task-group-section {
195 | padding-left: 6px;
196 | border-top: 1px solid #e2e2e2; }
197 |
198 | .task-group {
199 | padding-top: 0px; }
200 |
201 | .task-name-container a[name]:before {
202 | content: "";
203 | display: block;
204 | padding-top: 70px;
205 | margin: -70px 0 0; }
206 |
207 | .item {
208 | padding-top: 8px;
209 | width: 100%;
210 | list-style-type: none; }
211 | .item a[name]:before {
212 | content: "";
213 | display: block;
214 | padding-top: 70px;
215 | margin: -70px 0 0; }
216 | .item code {
217 | background-color: transparent;
218 | padding: 0; }
219 | .item .token {
220 | padding-left: 3px;
221 | margin-left: 15px;
222 | font-size: 11.9px; }
223 | .item .declaration-note {
224 | font-size: .85em;
225 | color: gray;
226 | font-style: italic; }
227 |
228 | .pointer-container {
229 | border-bottom: 1px solid #e2e2e2;
230 | left: -23px;
231 | padding-bottom: 13px;
232 | position: relative;
233 | width: 110%; }
234 |
235 | .pointer {
236 | background: #f9f9f9;
237 | border-left: 1px solid #e2e2e2;
238 | border-top: 1px solid #e2e2e2;
239 | height: 12px;
240 | left: 21px;
241 | top: -7px;
242 | -webkit-transform: rotate(45deg);
243 | -moz-transform: rotate(45deg);
244 | -o-transform: rotate(45deg);
245 | transform: rotate(45deg);
246 | position: absolute;
247 | width: 12px; }
248 |
249 | .height-container {
250 | display: none;
251 | left: -25px;
252 | padding: 0 25px;
253 | position: relative;
254 | width: 100%;
255 | overflow: hidden; }
256 | .height-container .section {
257 | background: #f9f9f9;
258 | border-bottom: 1px solid #e2e2e2;
259 | left: -25px;
260 | position: relative;
261 | width: 100%;
262 | padding-top: 10px;
263 | padding-bottom: 5px; }
264 |
265 | .aside, .language {
266 | padding: 6px 12px;
267 | margin: 12px 0;
268 | border-left: 5px solid #dddddd;
269 | overflow-y: hidden; }
270 | .aside .aside-title, .language .aside-title {
271 | font-size: 9px;
272 | letter-spacing: 2px;
273 | text-transform: uppercase;
274 | padding-bottom: 0;
275 | margin: 0;
276 | color: #aaa;
277 | -webkit-user-select: none; }
278 | .aside p:last-child, .language p:last-child {
279 | margin-bottom: 0; }
280 |
281 | .language {
282 | border-left: 5px solid #cde9f4; }
283 | .language .aside-title {
284 | color: #4b8afb; }
285 |
286 | .aside-warning {
287 | border-left: 5px solid #ff6666; }
288 | .aside-warning .aside-title {
289 | color: #ff0000; }
290 |
291 | .graybox {
292 | border-collapse: collapse;
293 | width: 100%; }
294 | .graybox p {
295 | margin: 0;
296 | word-break: break-word;
297 | min-width: 50px; }
298 | .graybox td {
299 | border: 1px solid #e2e2e2;
300 | padding: 5px 25px 5px 10px;
301 | vertical-align: middle; }
302 | .graybox tr td:first-of-type {
303 | text-align: right;
304 | padding: 7px;
305 | vertical-align: top;
306 | word-break: normal;
307 | width: 40px; }
308 |
309 | .slightly-smaller {
310 | font-size: 0.9em; }
311 |
312 | #footer {
313 | position: absolute;
314 | bottom: 10px;
315 | margin-left: 25px; }
316 | #footer p {
317 | margin: 0;
318 | color: #aaa;
319 | font-size: 0.8em; }
320 |
321 | html.dash header, html.dash #breadcrumbs, html.dash .sidebar {
322 | display: none; }
323 | html.dash .main-content {
324 | width: 980px;
325 | margin-left: 0;
326 | border: none;
327 | width: 100%;
328 | top: 0;
329 | padding-bottom: 0; }
330 | html.dash .height-container {
331 | display: block; }
332 | html.dash .item .token {
333 | margin-left: 0; }
334 | html.dash .content-wrapper {
335 | width: auto; }
336 | html.dash #footer {
337 | position: static; }
338 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/css/jazzy.css:
--------------------------------------------------------------------------------
1 | html, body, div, span, h1, h3, h4, p, a, code, em, img, ul, li, table, tbody, tr, td {
2 | background: transparent;
3 | border: 0;
4 | margin: 0;
5 | outline: 0;
6 | padding: 0;
7 | vertical-align: baseline; }
8 |
9 | body {
10 | background-color: #f2f2f2;
11 | font-family: Helvetica, freesans, Arial, sans-serif;
12 | font-size: 14px;
13 | -webkit-font-smoothing: subpixel-antialiased;
14 | word-wrap: break-word; }
15 |
16 | h1, h2, h3 {
17 | margin-top: 0.8em;
18 | margin-bottom: 0.3em;
19 | font-weight: 100;
20 | color: black; }
21 |
22 | h1 {
23 | font-size: 2.5em; }
24 |
25 | h2 {
26 | font-size: 2em;
27 | border-bottom: 1px solid #e2e2e2; }
28 |
29 | h4 {
30 | font-size: 13px;
31 | line-height: 1.5;
32 | margin-top: 21px; }
33 |
34 | h5 {
35 | font-size: 1.1em; }
36 |
37 | h6 {
38 | font-size: 1.1em;
39 | color: #777; }
40 |
41 | .section-name {
42 | color: gray;
43 | display: block;
44 | font-family: Helvetica;
45 | font-size: 22px;
46 | font-weight: 100;
47 | margin-bottom: 15px; }
48 |
49 | pre, code {
50 | font: 0.95em Menlo, monospace;
51 | color: #777;
52 | word-wrap: normal; }
53 |
54 | p code, li code {
55 | background-color: #eee;
56 | padding: 2px 4px;
57 | border-radius: 4px; }
58 |
59 | a {
60 | color: #0088cc;
61 | text-decoration: none; }
62 |
63 | ul {
64 | padding-left: 15px; }
65 |
66 | li {
67 | line-height: 1.8em; }
68 |
69 | img {
70 | max-width: 100%; }
71 |
72 | blockquote {
73 | margin-left: 0;
74 | padding: 0 10px;
75 | border-left: 4px solid #ccc; }
76 |
77 | .content-wrapper {
78 | margin: 0 auto;
79 | width: 980px; }
80 |
81 | header {
82 | font-size: 0.85em;
83 | line-height: 26px;
84 | background-color: #414141;
85 | position: fixed;
86 | width: 100%;
87 | z-index: 1; }
88 | header img {
89 | padding-right: 6px;
90 | vertical-align: -4px;
91 | height: 16px; }
92 | header a {
93 | color: #fff; }
94 | header p {
95 | float: left;
96 | color: #999; }
97 | header .header-right {
98 | float: right;
99 | margin-left: 16px; }
100 |
101 | #breadcrumbs {
102 | background-color: #f2f2f2;
103 | height: 27px;
104 | padding-top: 17px;
105 | position: fixed;
106 | width: 100%;
107 | z-index: 1;
108 | margin-top: 26px; }
109 | #breadcrumbs #carat {
110 | height: 10px;
111 | margin: 0 5px; }
112 |
113 | .sidebar {
114 | background-color: #f9f9f9;
115 | border: 1px solid #e2e2e2;
116 | overflow-y: auto;
117 | overflow-x: hidden;
118 | position: fixed;
119 | top: 70px;
120 | bottom: 0;
121 | width: 230px;
122 | word-wrap: normal; }
123 |
124 | .nav-groups {
125 | list-style-type: none;
126 | background: #fff;
127 | padding-left: 0; }
128 |
129 | .nav-group-name {
130 | border-bottom: 1px solid #e2e2e2;
131 | font-size: 1.1em;
132 | font-weight: 100;
133 | padding: 15px 0 15px 20px; }
134 | .nav-group-name > a {
135 | color: #333; }
136 |
137 | .nav-group-tasks {
138 | margin-top: 5px; }
139 |
140 | .nav-group-task {
141 | font-size: 0.9em;
142 | list-style-type: none;
143 | white-space: nowrap; }
144 | .nav-group-task a {
145 | color: #888; }
146 |
147 | .main-content {
148 | background-color: #fff;
149 | border: 1px solid #e2e2e2;
150 | margin-left: 246px;
151 | position: absolute;
152 | overflow: hidden;
153 | padding-bottom: 60px;
154 | top: 70px;
155 | width: 734px; }
156 | .main-content p, .main-content a, .main-content code, .main-content em, .main-content ul, .main-content table, .main-content blockquote {
157 | margin-bottom: 1em; }
158 | .main-content p {
159 | line-height: 1.8em; }
160 | .main-content section .section:first-child {
161 | margin-top: 0;
162 | padding-top: 0; }
163 | .main-content section .task-group-section .task-group:first-of-type {
164 | padding-top: 10px; }
165 | .main-content section .task-group-section .task-group:first-of-type .section-name {
166 | padding-top: 15px; }
167 | .main-content section .heading:before {
168 | content: "";
169 | display: block;
170 | padding-top: 70px;
171 | margin: -70px 0 0; }
172 |
173 | .section {
174 | padding: 0 25px; }
175 |
176 | .highlight {
177 | background-color: #eee;
178 | padding: 10px 12px;
179 | border: 1px solid #e2e2e2;
180 | border-radius: 4px;
181 | overflow-x: auto; }
182 |
183 | .declaration .highlight {
184 | overflow-x: initial;
185 | padding: 0 40px 40px 0;
186 | margin-bottom: -25px;
187 | background-color: transparent;
188 | border: none; }
189 |
190 | .section-name {
191 | margin: 0;
192 | margin-left: 18px; }
193 |
194 | .task-group-section {
195 | padding-left: 6px;
196 | border-top: 1px solid #e2e2e2; }
197 |
198 | .task-group {
199 | padding-top: 0px; }
200 |
201 | .task-name-container a[name]:before {
202 | content: "";
203 | display: block;
204 | padding-top: 70px;
205 | margin: -70px 0 0; }
206 |
207 | .item {
208 | padding-top: 8px;
209 | width: 100%;
210 | list-style-type: none; }
211 | .item a[name]:before {
212 | content: "";
213 | display: block;
214 | padding-top: 70px;
215 | margin: -70px 0 0; }
216 | .item code {
217 | background-color: transparent;
218 | padding: 0; }
219 | .item .token {
220 | padding-left: 3px;
221 | margin-left: 15px;
222 | font-size: 11.9px; }
223 | .item .declaration-note {
224 | font-size: .85em;
225 | color: gray;
226 | font-style: italic; }
227 |
228 | .pointer-container {
229 | border-bottom: 1px solid #e2e2e2;
230 | left: -23px;
231 | padding-bottom: 13px;
232 | position: relative;
233 | width: 110%; }
234 |
235 | .pointer {
236 | background: #f9f9f9;
237 | border-left: 1px solid #e2e2e2;
238 | border-top: 1px solid #e2e2e2;
239 | height: 12px;
240 | left: 21px;
241 | top: -7px;
242 | -webkit-transform: rotate(45deg);
243 | -moz-transform: rotate(45deg);
244 | -o-transform: rotate(45deg);
245 | transform: rotate(45deg);
246 | position: absolute;
247 | width: 12px; }
248 |
249 | .height-container {
250 | display: none;
251 | left: -25px;
252 | padding: 0 25px;
253 | position: relative;
254 | width: 100%;
255 | overflow: hidden; }
256 | .height-container .section {
257 | background: #f9f9f9;
258 | border-bottom: 1px solid #e2e2e2;
259 | left: -25px;
260 | position: relative;
261 | width: 100%;
262 | padding-top: 10px;
263 | padding-bottom: 5px; }
264 |
265 | .aside, .language {
266 | padding: 6px 12px;
267 | margin: 12px 0;
268 | border-left: 5px solid #dddddd;
269 | overflow-y: hidden; }
270 | .aside .aside-title, .language .aside-title {
271 | font-size: 9px;
272 | letter-spacing: 2px;
273 | text-transform: uppercase;
274 | padding-bottom: 0;
275 | margin: 0;
276 | color: #aaa;
277 | -webkit-user-select: none; }
278 | .aside p:last-child, .language p:last-child {
279 | margin-bottom: 0; }
280 |
281 | .language {
282 | border-left: 5px solid #cde9f4; }
283 | .language .aside-title {
284 | color: #4b8afb; }
285 |
286 | .aside-warning {
287 | border-left: 5px solid #ff6666; }
288 | .aside-warning .aside-title {
289 | color: #ff0000; }
290 |
291 | .graybox {
292 | border-collapse: collapse;
293 | width: 100%; }
294 | .graybox p {
295 | margin: 0;
296 | word-break: break-word;
297 | min-width: 50px; }
298 | .graybox td {
299 | border: 1px solid #e2e2e2;
300 | padding: 5px 25px 5px 10px;
301 | vertical-align: middle; }
302 | .graybox tr td:first-of-type {
303 | text-align: right;
304 | padding: 7px;
305 | vertical-align: top;
306 | word-break: normal;
307 | width: 40px; }
308 |
309 | .slightly-smaller {
310 | font-size: 0.9em; }
311 |
312 | #footer {
313 | position: absolute;
314 | bottom: 10px;
315 | margin-left: 25px; }
316 | #footer p {
317 | margin: 0;
318 | color: #aaa;
319 | font-size: 0.8em; }
320 |
321 | html.dash header, html.dash #breadcrumbs, html.dash .sidebar {
322 | display: none; }
323 | html.dash .main-content {
324 | width: 980px;
325 | margin-left: 0;
326 | border: none;
327 | width: 100%;
328 | top: 0;
329 | padding-bottom: 0; }
330 | html.dash .height-container {
331 | display: block; }
332 | html.dash .item .token {
333 | margin-left: 0; }
334 | html.dash .content-wrapper {
335 | width: auto; }
336 | html.dash #footer {
337 | position: static; }
338 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ColorSlider Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
22 |
23 | ColorSlider Reference
24 |
25 | ColorSlider Reference
26 |
27 |
28 |
29 |
69 |
70 |
71 |
72 |
73 |
74 |
ColorSlider
75 |
76 |
77 |
78 |
79 | ColorSlider is an iOS color picker with live preview written in Swift .
80 |
81 |
82 |
83 | Usage
84 |
85 | Create and add a ColorSlider to your view:
86 | let colorSlider = ColorSlider(orientation: .vertical, previewSide: .left)
87 | colorSlider.frame = CGRectMake(0, 0, 12, 150)
88 | view.addSubview(colorSlider)
89 |
90 |
91 | Respond to changes in color using UIControlEvents:
92 | colorSlider.addTarget(self, action: #selector(changedColor(_:)), forControlEvents: .valueChanged)
93 |
94 | func changedColor(_ slider: ColorSlider) {
95 | var color = slider.color
96 | // ...
97 | }
98 |
99 |
100 | Customize appearance attributes:
101 | // Add a border
102 | colorSlider.gradientView.layer.borderWidth = 2.0
103 | colorSlider.gradientView.layer.borderColor = UIColor.white
104 |
105 | // Disable rounded corners
106 | colorSlider.gradientView.automaticallyAdjustsCornerRadius = false
107 |
108 | Preview
109 |
110 | ColorSlider has a live preview that tracks touches along it. You can customize it:
111 | let previewView = ColorSlider.DefaultPreviewView()
112 | previewView.side = .right
113 | previewView.animationDuration = 0.2
114 | previewView.offsetAmount = 50
115 |
116 | let colorSlider = ColorSlider(orientation: .vertical, previewView: previewView)
117 |
118 |
119 | Create your own live preview by subclassing DefaultPreviewView or implementing ColorSliderPreviewing in your UIView subclass.
120 | Then, just pass your preview instance to the initializer:
121 | let customPreviewView = MyCustomPreviewView()
122 | let colorSlider = ColorSlider(orientation: .vertical, previewView: customPreviewView)
123 |
124 |
125 | ColorSlider will automatically update your view’s center as touches move on the slider.
126 | By default, it’ll also resize your preview automatically. Set colorSlider.autoresizesSubviews to false to disable autoresizing.
127 |
128 | To disable the preview, simply pass nil to ColorSlider’s initializer:
129 | let colorSlider = ColorSlider(orientation: .vertical, previewView: nil)
130 |
131 |
132 | See the documentation for more details on custom previews.
133 | Documentation
134 |
135 | ColorSlider is fully documented here .
136 | Installation
137 |
138 | platform :ios , '9.0'
139 | pod 'ColorSlider' , '~> 4.0'
140 |
141 |
142 | github "gizmosachin/ColorSlider" >= 4.0
143 |
144 | Version Compatibility
145 |
146 |
147 |
148 | Swift Version
149 | Framework Version
150 |
151 |
152 |
153 | 4.0
154 | master
155 |
156 |
157 | 3.0
158 | 3.0.1
159 |
160 |
161 | Demo
162 |
163 | Please see the Demo directory for a basic iOS project that uses ColorSlider.
164 | Contributing
165 |
166 | ColorSlider is a community - contributions and discussions are welcome!
167 |
168 | Please read the contributing guidelines prior to submitting a Pull Request.
169 | License
170 |
171 | ColorSlider is available under the MIT license, see the LICENSE file for more information.
172 |
173 |
174 |
175 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/Sources/DefaultPreviewView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DefaultPreviewView.swift
3 | //
4 | // Created by Sachin Patel on 9/5/17.
5 | //
6 | // The MIT License (MIT)
7 | //
8 | // Copyright (c) 2015-Present Sachin Patel (http://gizmosachin.com/)
9 | //
10 | // Permission is hereby granted, free of charge, to any person obtaining a copy
11 | // of this software and associated documentation files (the "Software"), to deal
12 | // in the Software without restriction, including without limitation the rights
13 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | // copies of the Software, and to permit persons to whom the Software is
15 | // furnished to do so, subject to the following conditions:
16 | //
17 | // The above copyright notice and this permission notice shall be included in all
18 | // copies or substantial portions of the Software.
19 | //
20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 | // SOFTWARE.
27 |
28 | import UIKit
29 |
30 | ///
31 | /// The default preview view of a `ColorSlider`.
32 | ///
33 | /// Appears to the given `side` of the associated `ColorSlider` at the point of the currently
34 | /// selected color with an offset of `offsetAmount` and a scale given by `scaleAmounts` for a given state.
35 | ///
36 | /// You can subclass this class and pass it as a preview to `ColorSlider` to customize its appearance or animation.
37 | /// You may also create your own custom `UIView` and conform to the `PreviewView` protocol and pass that to `ColorSlider`'s initializer.
38 | ///
39 |
40 | public class DefaultPreviewView: UIView {
41 | /// The animation duration when showing the preview. Defaults to `0.15`.
42 | public var animationDuration: TimeInterval = 0.15
43 |
44 | /// The side of the `ColorSlider` on which to show the preview view.
45 | public enum Side {
46 | /// Show the preview to the left of the slider. Valid when the ColorSlider orientation is vertical.
47 | case left
48 |
49 | /// Show the preview to the right of the slider. Valid when the ColorSlider orientation is vertical.
50 | case right
51 |
52 | /// Show the preview to the top of the slider. Valid when the ColorSlider orientation is horizontal.
53 | case top
54 |
55 | /// Show the preview to the bottom of the slider. Valid when the ColorSlider orientation is horizontal.
56 | case bottom
57 | }
58 |
59 | /// The side of the ColorSlider that the preview should show on. Defaults to `.left`.
60 | public var side: Side {
61 | didSet {
62 | calculateOffset()
63 | }
64 | }
65 |
66 | /// The scale of the slider for each preview state.
67 | /// Defaults to:
68 | /// * `.inactive`: `1`
69 | /// * `.activeFixed`: `1.2`
70 | /// * `.active`: `1.6`
71 | public var scaleAmounts: [PreviewState: CGFloat] = [.inactive: 1.0,
72 | .activeFixed: 1.2,
73 | .active: 1.6]
74 |
75 | /// The number of points to offset the preview view from the slider when the state is set to `.active`. Defaults to `50`.
76 | public var offsetAmount: CGFloat = 50 {
77 | didSet {
78 | calculateOffset()
79 | }
80 | }
81 |
82 | /// The actual offset of the preview view, calculated from `offsetAmount` and `side`.
83 | /// This value is calculated automatically in `calculateOffset` and should only be modified externally by subclasses.
84 | public var offset: CGPoint
85 |
86 | /// The view that displays the current color as its `backgroundColor`.
87 | public let colorView: UIView = UIView()
88 |
89 | /// Enable haptics on iPhone 7 and above for state transitions to/from `.activeFixed`. Defaults to `true`.
90 | public var hapticsEnabled: Bool = true
91 |
92 | /// :nodoc:
93 | /// The last state that occurred, used to trigger haptic feedback when a selection occurs.
94 | fileprivate var lastState: PreviewState = .inactive
95 |
96 | /// Initialize with a specific side.
97 | /// - parameter side: The side of the `ColorSlider` to show on. Defaults to `.left`.
98 | required public init(side: Side = .left) {
99 | self.side = side
100 | colorView.backgroundColor = .red
101 | offset = CGPoint(x: -offsetAmount, y: 0)
102 |
103 | super.init(frame: .zero)
104 |
105 | backgroundColor = .white
106 |
107 | // Outer shadow
108 | layer.shadowColor = UIColor.black.cgColor
109 | layer.shadowRadius = 3
110 | layer.shadowOpacity = 0.2
111 | layer.shadowOffset = CGSize(width: 2, height: 2)
112 |
113 | // Borders
114 | colorView.clipsToBounds = true
115 | colorView.layer.borderWidth = 1.0
116 | colorView.layer.borderColor = UIColor.black.withAlphaComponent(0.1).cgColor
117 | addSubview(colorView)
118 |
119 | calculateOffset()
120 | }
121 |
122 | /// :nodoc:
123 | public required init?(coder aDecoder: NSCoder) {
124 | fatalError("init(coder:) has not been implemented")
125 | }
126 |
127 | /// :nodoc:
128 | override public func layoutSubviews() {
129 | super.layoutSubviews()
130 |
131 | // Automatically set the preview view corner radius based on the shortest side
132 | layer.cornerRadius = min(bounds.width, bounds.height) / 2
133 |
134 | // Inset the color view by 3 points, round the corners
135 | let colorViewFrame = bounds.insetBy(dx: 3, dy: 3)
136 | colorView.frame = colorViewFrame
137 | colorView.layer.cornerRadius = min(colorViewFrame.width, colorViewFrame.height) / 2
138 | }
139 |
140 | /// Calculate the offset of the preview view when `offset` or `side` are set.
141 | public func calculateOffset() {
142 | switch side {
143 | case .left:
144 | offset = CGPoint(x: -offsetAmount, y: 0)
145 | case .right:
146 | offset = CGPoint(x: offsetAmount, y: 0)
147 | case .top:
148 | offset = CGPoint(x: 0, y: -offsetAmount)
149 | case .bottom:
150 | offset = CGPoint(x: 0, y: offsetAmount)
151 | }
152 | }
153 | }
154 |
155 | extension DefaultPreviewView: ColorSliderPreviewing {
156 | /// Set the `backgroundColor` of `colorView` to the new `color`.
157 | /// - parameter color: The new color.
158 | public func colorChanged(to color: UIColor) {
159 | colorView.backgroundColor = color
160 | }
161 |
162 | /// Animating to the `CGAffineTransform` with:
163 | /// * Translation: `offset`
164 | /// * Scale: `scaleAmounts[state]`
165 | /// - seealso: `offsetAmount`
166 | /// - seealso: `scaleAmounts`
167 | /// - seealso: `offset`
168 | /// - parameter state: The new state to transition to.
169 | public func transition(to state: PreviewState) {
170 | // The `.beginFromCurrentState` option allows there to be no delay when another touch occurs and a previous transition hasn't finished.
171 | UIView.animate(withDuration: animationDuration, delay: 0, options: [.curveEaseInOut, .beginFromCurrentState], animations: {
172 | // Only show the outer shadow when the state is inactive.
173 | self.colorView.layer.borderWidth = (state == .inactive ? 0 : 1)
174 |
175 | switch state {
176 |
177 | // Set the transform based on `scaleAmounts`.
178 | case .inactive,
179 | .activeFixed:
180 | let scaleAmount = self.scaleAmounts[state] ?? 1
181 | let scaleTransform = CGAffineTransform(scaleX: scaleAmount, y: scaleAmount)
182 | self.transform = scaleTransform
183 |
184 | // Set the transform based on `scaleAmounts` and `offset`.
185 | case .active:
186 | let scaleAmount = self.scaleAmounts[state] ?? 1
187 | let scaleTransform = CGAffineTransform(scaleX: scaleAmount, y: scaleAmount)
188 | let translationTransform = CGAffineTransform(translationX: self.offset.x, y: self.offset.y)
189 | self.transform = scaleTransform.concatenating(translationTransform)
190 |
191 | }
192 | }, completion: nil)
193 |
194 | // Haptics
195 | if hapticsEnabled, #available(iOS 10.0, *) {
196 | switch (lastState, state) {
197 |
198 | // Medium impact haptic when first drag outside bounds occurs.
199 | case (.active, .activeFixed):
200 | let impactFeedback = UIImpactFeedbackGenerator(style: .medium)
201 | impactFeedback.impactOccurred()
202 |
203 | // Light impact haptic when color selection outside bounds occurs.
204 | case (.activeFixed, .inactive):
205 | let impactFeedback = UIImpactFeedbackGenerator(style: .light)
206 | impactFeedback.impactOccurred()
207 |
208 | // No haptic feedback for other state transitions.
209 | default:
210 | break
211 |
212 | }
213 | }
214 |
215 | lastState = state
216 | }
217 | }
218 |
--------------------------------------------------------------------------------
/docs/Enums/PreviewState.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PreviewState Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | PreviewState Enum Reference
27 |
28 |
29 |
30 |
70 |
71 |
72 |
73 | PreviewState
74 |
75 |
76 |
public enum PreviewState
77 |
78 |
79 |
80 | The display state of a preview view.
81 |
82 |
83 |
84 |
85 |
86 |
87 |
94 |
95 |
96 |
97 |
98 |
99 |
The color is not being changed and the preview view is centered at the last modified point.
100 |
101 |
102 |
103 |
Declaration
104 |
105 |
Swift
106 |
case inactive
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
125 |
126 |
127 |
128 |
129 |
130 |
The color is still being changed, but the preview view center is fixed.
131 | This occurs when a touch begins inside the slider but continues outside of it.
132 | In this case, the color is actively being modified, but the preview remains fixed at
133 | the same position that it was when the touch moved outside of the slider.
134 |
135 |
136 |
137 |
Declaration
138 |
139 |
Swift
140 |
case activeFixed
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 | active
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
The color is being actively changed and the preview view center will be updated to match the current color.
165 |
166 |
167 |
168 |
Declaration
169 |
170 |
Swift
171 |
case active
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
186 |
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/Enums/PreviewState.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PreviewState Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | PreviewState Enum Reference
27 |
28 |
29 |
30 |
70 |
71 |
72 |
73 | PreviewState
74 |
75 |
76 |
public enum PreviewState
77 |
78 |
79 |
80 | The display state of a preview view.
81 |
82 |
83 |
84 |
85 |
86 |
87 |
94 |
95 |
96 |
97 |
98 |
99 |
The color is not being changed and the preview view is centered at the last modified point.
100 |
101 |
102 |
103 |
Declaration
104 |
105 |
Swift
106 |
case inactive
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
125 |
126 |
127 |
128 |
129 |
130 |
The color is still being changed, but the preview view center is fixed.
131 | This occurs when a touch begins inside the slider but continues outside of it.
132 | In this case, the color is actively being modified, but the preview remains fixed at
133 | the same position that it was when the touch moved outside of the slider.
134 |
135 |
136 |
137 |
Declaration
138 |
139 |
Swift
140 |
case activeFixed
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 | active
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
The color is being actively changed and the preview view center will be updated to match the current color.
165 |
166 |
167 |
168 |
Declaration
169 |
170 |
Swift
171 |
case active
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
186 |
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------
/docs/search.json:
--------------------------------------------------------------------------------
1 | {"Protocols/ColorSliderPreviewing.html#/s:11ColorSlider0aB10PreviewingP12colorChangedySo7UIColorC2to_tF":{"name":"colorChanged(to:)","abstract":"Called when the color of the slider changes, so the preview can respond correctly.
","parent_name":"ColorSliderPreviewing"},"Protocols/ColorSliderPreviewing.html#/s:11ColorSlider0aB10PreviewingP10transitionyAA12PreviewStateO2to_tF":{"name":"transition(to:)","abstract":"Called when the preview changes state and should update its appearance appropriately.","parent_name":"ColorSliderPreviewing"},"Protocols/ColorSliderPreviewing.html":{"name":"ColorSliderPreviewing","abstract":"
A protocol defining callback methods for a ColorSlider preview view.
"},"Enums/PreviewState.html#/s:11ColorSlider12PreviewStateO8inactiveA2CmF":{"name":"inactive","abstract":"The color is not being changed and the preview view is centered at the last modified point.
","parent_name":"PreviewState"},"Enums/PreviewState.html#/s:11ColorSlider12PreviewStateO11activeFixedA2CmF":{"name":"activeFixed","abstract":"The color is still being changed, but the preview view center is fixed.","parent_name":"PreviewState"},"Enums/PreviewState.html#/s:11ColorSlider12PreviewStateO6activeA2CmF":{"name":"active","abstract":"
The color is being actively changed and the preview view center will be updated to match the current color.
","parent_name":"PreviewState"},"Enums/Orientation.html#/s:11ColorSlider11OrientationO10horizontalA2CmF":{"name":"horizontal","abstract":"The horizontal orientation.
","parent_name":"Orientation"},"Enums/Orientation.html#/s:11ColorSlider11OrientationO8verticalA2CmF":{"name":"vertical","abstract":"The vertical orientation.
","parent_name":"Orientation"},"Enums/Orientation.html":{"name":"Orientation","abstract":"The orientation in which the ColorSlider is drawn.
"},"Enums/PreviewState.html":{"name":"PreviewState","abstract":"The display state of a preview view.
"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO4leftA2EmF":{"name":"left","abstract":"Show the preview to the left of the slider. Valid when the ColorSlider orientation is vertical.
","parent_name":"Side"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO5rightA2EmF":{"name":"right","abstract":"Show the preview to the right of the slider. Valid when the ColorSlider orientation is vertical.
","parent_name":"Side"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO3topA2EmF":{"name":"top","abstract":"Show the preview to the top of the slider. Valid when the ColorSlider orientation is horizontal.
","parent_name":"Side"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO6bottomA2EmF":{"name":"bottom","abstract":"Show the preview to the bottom of the slider. Valid when the ColorSlider orientation is horizontal.
","parent_name":"Side"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)animationDuration":{"name":"animationDuration","abstract":"The animation duration when showing the preview. Defaults to 0.15.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView/Side.html":{"name":"Side","abstract":"The side of the ColorSlider on which to show the preview view.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewC4sideAC4SideOv":{"name":"side","abstract":"The side of the ColorSlider that the preview should show on. Defaults to .left.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewC12scaleAmountss10DictionaryVyAA0D5StateO12CoreGraphics7CGFloatVGv":{"name":"scaleAmounts","abstract":"The scale of the slider for each preview state.","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)offsetAmount":{"name":"offsetAmount","abstract":"
The number of points to offset the preview view from the slider when the state is set to .active. Defaults to 50.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)offset":{"name":"offset","abstract":"The actual offset of the preview view, calculated from offsetAmount and side .","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)colorView":{"name":"colorView","abstract":"
The view that displays the current color as its backgroundColor.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)hapticsEnabled":{"name":"hapticsEnabled","abstract":"Enable haptics on iPhone 7 and above for state transitions to/from .activeFixed. Defaults to true.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewCA2C4SideO4side_tcfc":{"name":"init(side:)","abstract":"Initialize with a specific side.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(im)calculateOffset":{"name":"calculateOffset()","abstract":"Calculate the offset of the preview view when offset or side are set.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@CM@ColorSlider@objc(cs)DefaultPreviewView(im)colorChangedTo:":{"name":"colorChanged(to:)","abstract":"Set the backgroundColor of colorView to the new color.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewC10transitionyAA0D5StateO2to_tF":{"name":"transition(to:)","abstract":"Animating to the CGAffineTransform with:
","parent_name":"DefaultPreviewView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)automaticallyAdjustsCornerRadius":{"name":"automaticallyAdjustsCornerRadius","abstract":"Whether the gradient should adjust its corner radius based on its bounds.","parent_name":"GradientView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)saturation":{"name":"saturation","abstract":"
The saturation of all colors in the view.","parent_name":"GradientView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)whiteInset":{"name":"whiteInset","abstract":"
The percent of space at the beginning (top for orientation .vertical and left for orientation .horizontal) end of the slider reserved for the color white.","parent_name":"GradientView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)blackInset":{"name":"blackInset","abstract":"
The percent of space at the end (bottom for orientation .vertical and right for orientation .horizontal) end of the slider reserved for the color black.","parent_name":"GradientView"},"Classes/GradientView.html#/s:11ColorSlider12GradientViewCAcA11OrientationO11orientation_tcfc":{"name":"init(orientation:)","parent_name":"GradientView"},"Classes/ColorSlider.html#/c:@M@ColorSlider@objc(cs)ColorSlider(py)color":{"name":"color","abstract":"
The selected color.
","parent_name":"ColorSlider"},"Classes/ColorSlider.html#/c:@M@ColorSlider@objc(cs)ColorSlider(py)gradientView":{"name":"gradientView","abstract":"The background gradient view.
","parent_name":"ColorSlider"},"Classes/ColorSlider.html#/s:11ColorSliderAAC11previewViewAA0aB10Previewing_So6UIViewCXcSgv":{"name":"previewView","abstract":"The preview view, passed in the required initializer.
","parent_name":"ColorSlider"},"Classes/ColorSlider.html#/s:11ColorSliderAACAbA11OrientationO11orientation_AA0aB10Previewing_So6UIViewCXcSg11previewViewtcfc":{"name":"init(orientation:previewView:)","parent_name":"ColorSlider"},"Classes/ColorSlider.html":{"name":"ColorSlider","abstract":"ColorSlider is a customizable color picker with live preview.
"},"Classes/GradientView.html":{"name":"GradientView","abstract":"A gradient view that acts as the background of any ColorSlider ."},"Classes/DefaultPreviewView.html":{"name":"DefaultPreviewView","abstract":"
The default preview view of a ColorSlider .
"},"Classes.html":{"name":"Classes","abstract":"The following classes are available globally.
"},"Enums.html":{"name":"Enums","abstract":"The following enums are available globally.
"},"Protocols.html":{"name":"Protocols","abstract":"The following protocols are available globally.
"}}
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/search.json:
--------------------------------------------------------------------------------
1 | {"Protocols/ColorSliderPreviewing.html#/s:11ColorSlider0aB10PreviewingP12colorChangedySo7UIColorC2to_tF":{"name":"colorChanged(to:)","abstract":"Called when the color of the slider changes, so the preview can respond correctly.
","parent_name":"ColorSliderPreviewing"},"Protocols/ColorSliderPreviewing.html#/s:11ColorSlider0aB10PreviewingP10transitionyAA12PreviewStateO2to_tF":{"name":"transition(to:)","abstract":"Called when the preview changes state and should update its appearance appropriately.","parent_name":"ColorSliderPreviewing"},"Protocols/ColorSliderPreviewing.html":{"name":"ColorSliderPreviewing","abstract":"
A protocol defining callback methods for a ColorSlider preview view.
"},"Enums/PreviewState.html#/s:11ColorSlider12PreviewStateO8inactiveA2CmF":{"name":"inactive","abstract":"The color is not being changed and the preview view is centered at the last modified point.
","parent_name":"PreviewState"},"Enums/PreviewState.html#/s:11ColorSlider12PreviewStateO11activeFixedA2CmF":{"name":"activeFixed","abstract":"The color is still being changed, but the preview view center is fixed.","parent_name":"PreviewState"},"Enums/PreviewState.html#/s:11ColorSlider12PreviewStateO6activeA2CmF":{"name":"active","abstract":"
The color is being actively changed and the preview view center will be updated to match the current color.
","parent_name":"PreviewState"},"Enums/Orientation.html#/s:11ColorSlider11OrientationO10horizontalA2CmF":{"name":"horizontal","abstract":"The horizontal orientation.
","parent_name":"Orientation"},"Enums/Orientation.html#/s:11ColorSlider11OrientationO8verticalA2CmF":{"name":"vertical","abstract":"The vertical orientation.
","parent_name":"Orientation"},"Enums/Orientation.html":{"name":"Orientation","abstract":"The orientation in which the ColorSlider is drawn.
"},"Enums/PreviewState.html":{"name":"PreviewState","abstract":"The display state of a preview view.
"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO4leftA2EmF":{"name":"left","abstract":"Show the preview to the left of the slider. Valid when the ColorSlider orientation is vertical.
","parent_name":"Side"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO5rightA2EmF":{"name":"right","abstract":"Show the preview to the right of the slider. Valid when the ColorSlider orientation is vertical.
","parent_name":"Side"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO3topA2EmF":{"name":"top","abstract":"Show the preview to the top of the slider. Valid when the ColorSlider orientation is horizontal.
","parent_name":"Side"},"Classes/DefaultPreviewView/Side.html#/s:11ColorSlider18DefaultPreviewViewC4SideO6bottomA2EmF":{"name":"bottom","abstract":"Show the preview to the bottom of the slider. Valid when the ColorSlider orientation is horizontal.
","parent_name":"Side"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)animationDuration":{"name":"animationDuration","abstract":"The animation duration when showing the preview. Defaults to 0.15.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView/Side.html":{"name":"Side","abstract":"The side of the ColorSlider on which to show the preview view.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewC4sideAC4SideOv":{"name":"side","abstract":"The side of the ColorSlider that the preview should show on. Defaults to .left.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewC12scaleAmountss10DictionaryVyAA0D5StateO12CoreGraphics7CGFloatVGv":{"name":"scaleAmounts","abstract":"The scale of the slider for each preview state.","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)offsetAmount":{"name":"offsetAmount","abstract":"
The number of points to offset the preview view from the slider when the state is set to .active. Defaults to 50.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)offset":{"name":"offset","abstract":"The actual offset of the preview view, calculated from offsetAmount and side .","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)colorView":{"name":"colorView","abstract":"
The view that displays the current color as its backgroundColor.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(py)hapticsEnabled":{"name":"hapticsEnabled","abstract":"Enable haptics on iPhone 7 and above for state transitions to/from .activeFixed. Defaults to true.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewCA2C4SideO4side_tcfc":{"name":"init(side:)","abstract":"Initialize with a specific side.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@M@ColorSlider@objc(cs)DefaultPreviewView(im)calculateOffset":{"name":"calculateOffset()","abstract":"Calculate the offset of the preview view when offset or side are set.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/c:@CM@ColorSlider@objc(cs)DefaultPreviewView(im)colorChangedTo:":{"name":"colorChanged(to:)","abstract":"Set the backgroundColor of colorView to the new color.
","parent_name":"DefaultPreviewView"},"Classes/DefaultPreviewView.html#/s:11ColorSlider18DefaultPreviewViewC10transitionyAA0D5StateO2to_tF":{"name":"transition(to:)","abstract":"Animating to the CGAffineTransform with:
","parent_name":"DefaultPreviewView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)automaticallyAdjustsCornerRadius":{"name":"automaticallyAdjustsCornerRadius","abstract":"Whether the gradient should adjust its corner radius based on its bounds.","parent_name":"GradientView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)saturation":{"name":"saturation","abstract":"
The saturation of all colors in the view.","parent_name":"GradientView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)whiteInset":{"name":"whiteInset","abstract":"
The percent of space at the beginning (top for orientation .vertical and left for orientation .horizontal) end of the slider reserved for the color white.","parent_name":"GradientView"},"Classes/GradientView.html#/c:@M@ColorSlider@objc(cs)GradientView(py)blackInset":{"name":"blackInset","abstract":"
The percent of space at the end (bottom for orientation .vertical and right for orientation .horizontal) end of the slider reserved for the color black.","parent_name":"GradientView"},"Classes/GradientView.html#/s:11ColorSlider12GradientViewCAcA11OrientationO11orientation_tcfc":{"name":"init(orientation:)","parent_name":"GradientView"},"Classes/ColorSlider.html#/c:@M@ColorSlider@objc(cs)ColorSlider(py)color":{"name":"color","abstract":"
The selected color.
","parent_name":"ColorSlider"},"Classes/ColorSlider.html#/c:@M@ColorSlider@objc(cs)ColorSlider(py)gradientView":{"name":"gradientView","abstract":"The background gradient view.
","parent_name":"ColorSlider"},"Classes/ColorSlider.html#/s:11ColorSliderAAC11previewViewAA0aB10Previewing_So6UIViewCXcSgv":{"name":"previewView","abstract":"The preview view, passed in the required initializer.
","parent_name":"ColorSlider"},"Classes/ColorSlider.html#/s:11ColorSliderAACAbA11OrientationO11orientation_AA0aB10Previewing_So6UIViewCXcSg11previewViewtcfc":{"name":"init(orientation:previewView:)","parent_name":"ColorSlider"},"Classes/ColorSlider.html":{"name":"ColorSlider","abstract":"ColorSlider is a customizable color picker with live preview.
"},"Classes/GradientView.html":{"name":"GradientView","abstract":"A gradient view that acts as the background of any ColorSlider ."},"Classes/DefaultPreviewView.html":{"name":"DefaultPreviewView","abstract":"
The default preview view of a ColorSlider .
"},"Classes.html":{"name":"Classes","abstract":"The following classes are available globally.
"},"Enums.html":{"name":"Enums","abstract":"The following enums are available globally.
"},"Protocols.html":{"name":"Protocols","abstract":"The following protocols are available globally.
"}}
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ColorSlider Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
22 |
23 | ColorSlider Reference
24 |
25 | ColorSlider Reference
26 |
27 |
28 |
29 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | ColorSlider is an iOS color picker with live preview written in Swift .
80 |
81 |
82 |
83 |
84 |
85 |
86 | Features
87 |
88 |
89 |
90 | :ghost:
91 | [Snapchat](http://snapchat.com)-style color picker
92 |
93 |
94 | :rainbow:
95 | Extensible live preview
96 |
97 |
98 | :art:
99 | Customizable appearance
100 |
101 |
102 | :cyclone:
103 | Vertical and horizontal support
104 |
105 |
106 | :musical_keyboard:
107 | Black and white colors included
108 |
109 |
110 | :books:
111 | Fully documented
112 |
113 |
114 | :baby_chick:
115 | Swift 4
116 |
117 |
118 | Usage
119 |
120 | Create and add a ColorSlider to your view:
121 | let colorSlider = ColorSlider(orientation: .vertical, previewSide: .left)
122 | colorSlider.frame = CGRectMake(0, 0, 12, 150)
123 | view.addSubview(colorSlider)
124 |
125 |
126 | Respond to changes in color using UIControlEvents:
127 | colorSlider.addTarget(self, action: #selector(changedColor(_:)), forControlEvents: .valueChanged)
128 |
129 | func changedColor(_ slider: ColorSlider) {
130 | var color = slider.color
131 | // ...
132 | }
133 |
134 |
135 | Customize appearance attributes:
136 | // Add a border
137 | colorSlider.gradientView.layer.borderWidth = 2.0
138 | colorSlider.gradientView.layer.borderColor = UIColor.white
139 |
140 | // Disable rounded corners
141 | colorSlider.gradientView.automaticallyAdjustsCornerRadius = false
142 |
143 | Preview
144 |
145 | ColorSlider has a live preview that tracks touches along it. You can customize it:
146 | let previewView = ColorSlider.DefaultPreviewView()
147 | previewView.side = .right
148 | previewView.animationDuration = 0.2
149 | previewView.offsetAmount = 50
150 |
151 | let colorSlider = ColorSlider(orientation: .vertical, previewView: previewView)
152 |
153 |
154 | Create your own live preview by subclassing DefaultPreviewView or implementing ColorSliderPreviewing in your UIView subclass.
155 | Then, just pass your preview instance to the initializer:
156 | let customPreviewView = MyCustomPreviewView()
157 | let colorSlider = ColorSlider(orientation: .vertical, previewView: customPreviewView)
158 |
159 |
160 | ColorSlider will automatically update your view’s center as touches move on the slider.
161 | By default, it’ll also resize your preview automatically. Set colorSlider.autoresizesSubviews to false to disable autoresizing.
162 |
163 | To disable the preview, simply pass nil to ColorSlider’s initializer:
164 | let colorSlider = ColorSlider(orientation: .vertical, previewView: nil)
165 |
166 |
167 | See the documentation for more details on custom previews.
168 | Documentation
169 |
170 | ColorSlider is fully documented here .
171 | Installation
172 |
173 | platform :ios , '9.0'
174 | pod 'ColorSlider' , '~> 4.0'
175 |
176 |
177 | github "gizmosachin/ColorSlider" >= 4.0
178 |
179 | Version Compatibility
180 |
181 |
182 |
183 | Swift Version
184 | Framework Version
185 |
186 |
187 |
188 | 4.0
189 | master
190 |
191 |
192 | 3.0
193 | 3.0.1
194 |
195 |
196 | Demo
197 |
198 | Please see the Demo directory for a basic iOS project that uses ColorSlider.
199 | Contributing
200 |
201 | ColorSlider is a community - contributions and discussions are welcome!
202 |
203 | Please read the contributing guidelines prior to submitting a Pull Request.
204 | License
205 |
206 | ColorSlider is available under the MIT license, see the LICENSE file for more information.
207 |
208 |
209 |
210 |
214 |
215 |
216 |
217 |
218 |
219 |
--------------------------------------------------------------------------------
/docs/Classes/DefaultPreviewView/Side.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Side Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | Side Enum Reference
27 |
28 |
29 |
30 |
70 |
71 |
72 |
73 | Side
74 |
75 |
76 |
public enum Side
77 |
78 |
79 |
80 | The side of the ColorSlider on which to show the preview view.
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | left
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
Show the preview to the left of the slider. Valid when the ColorSlider orientation is vertical.
100 |
101 |
102 |
103 |
Declaration
104 |
105 |
Swift
106 |
case left
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | right
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
Show the preview to the right of the slider. Valid when the ColorSlider orientation is vertical.
131 |
132 |
133 |
134 |
Declaration
135 |
136 |
Swift
137 |
case right
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | top
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
Show the preview to the top of the slider. Valid when the ColorSlider orientation is horizontal.
162 |
163 |
164 |
165 |
Declaration
166 |
167 |
Swift
168 |
case top
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 | bottom
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
Show the preview to the bottom of the slider. Valid when the ColorSlider orientation is horizontal.
193 |
194 |
195 |
196 |
Declaration
197 |
198 |
Swift
199 |
case bottom
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
214 |
215 |
216 |
217 |
218 |
219 |
--------------------------------------------------------------------------------
/docs/docsets/ColorSlider.docset/Contents/Resources/Documents/Classes/DefaultPreviewView/Side.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Side Enum Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 | ColorSlider Reference
25 |
26 | Side Enum Reference
27 |
28 |
29 |
30 |
70 |
71 |
72 |
73 | Side
74 |
75 |
76 |
public enum Side
77 |
78 |
79 |
80 | The side of the ColorSlider on which to show the preview view.
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | left
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
Show the preview to the left of the slider. Valid when the ColorSlider orientation is vertical.
100 |
101 |
102 |
103 |
Declaration
104 |
105 |
Swift
106 |
case left
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | right
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
Show the preview to the right of the slider. Valid when the ColorSlider orientation is vertical.
131 |
132 |
133 |
134 |
Declaration
135 |
136 |
Swift
137 |
case right
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | top
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
Show the preview to the top of the slider. Valid when the ColorSlider orientation is horizontal.
162 |
163 |
164 |
165 |
Declaration
166 |
167 |
Swift
168 |
case top
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 | bottom
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
Show the preview to the bottom of the slider. Valid when the ColorSlider orientation is horizontal.
193 |
194 |
195 |
196 |
Declaration
197 |
198 |
Swift
199 |
case bottom
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
214 |
215 |
216 |
217 |
218 |
219 |
--------------------------------------------------------------------------------