5 Commits

Author SHA1 Message Date
Ryan Ackermann dc8a7ccaa1 added a way to update the picker’s color 2020-04-29 10:34:04 -07:00
Ryan Ackermann 77abafa07f updated the sample project for Xcode 11 & Swift 5 2020-04-29 10:15:01 -07:00
Ryan Ackermann fc5abc1501 added a gitignore 2020-04-29 10:13:47 -07:00
Ryan Ackermann f40c39b3a8 updated the README
added a Carthage install explanation
2018-08-04 11:47:48 -05:00
Ryan Ackermann 2d47f2f17b exported the value variable for the carthage framework 2018-08-04 11:42:17 -05:00
31 changed files with 215 additions and 1151 deletions
Vendored
BIN
View File
Binary file not shown.
+68
View File
@@ -0,0 +1,68 @@
# Created by https://www.gitignore.io/api/xcode,macos
# Edit at https://www.gitignore.io/?templates=xcode,macos
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Xcode Patch
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
### Xcode Patch ###
**/xcshareddata/WorkspaceSettings.xcsettings
# End of https://www.gitignore.io/api/xcode,macos
+28 -10
View File
@@ -7,7 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
48A9BFBF20BED26800AC149A /* RAScrollablePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48A9BFBE20BED26800AC149A /* RAScrollablePickerView.swift */; };
48D1A6E921160D36007221D1 /* RAScrollablePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48D1A6E821160D36007221D1 /* RAScrollablePickerView.swift */; };
6908F4291B500AE500A410E2 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6908F4281B500AE500A410E2 /* WindowController.swift */; };
6908F42B1B500AE500A410E2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6908F42A1B500AE500A410E2 /* ViewController.swift */; };
6908F42E1B500AE500A410E2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6908F42C1B500AE500A410E2 /* Main.storyboard */; };
@@ -16,7 +16,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
48A9BFBE20BED26800AC149A /* RAScrollablePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RAScrollablePickerView.swift; sourceTree = SOURCE_ROOT; };
48D1A6E821160D36007221D1 /* RAScrollablePickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RAScrollablePickerView.swift; path = Framework/RAScrollablePickerView/RAScrollablePickerView/RAScrollablePickerView.swift; sourceTree = SOURCE_ROOT; };
6908F4231B500AE500A410E2 /* ColorPickerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ColorPickerExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
6908F4271B500AE500A410E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6908F4281B500AE500A410E2 /* WindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
@@ -57,7 +57,7 @@
isa = PBXGroup;
children = (
6908F42A1B500AE500A410E2 /* ViewController.swift */,
48A9BFBE20BED26800AC149A /* RAScrollablePickerView.swift */,
48D1A6E821160D36007221D1 /* RAScrollablePickerView.swift */,
6908F4261B500AE500A410E2 /* Supporting Files */,
);
path = ColorPickerExample;
@@ -101,7 +101,7 @@
6908F41B1B500AE500A410E2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0810;
LastUpgradeCheck = 1140;
ORGANIZATIONNAME = "Ryan Ackermann";
TargetAttributes = {
6908F4221B500AE500A410E2 = {
@@ -113,7 +113,7 @@
};
buildConfigurationList = 6908F41E1B500AE500A410E2 /* Build configuration list for PBXProject "ColorPickerExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -148,7 +148,7 @@
buildActionMask = 2147483647;
files = (
6908F42B1B500AE500A410E2 /* ViewController.swift in Sources */,
48A9BFBF20BED26800AC149A /* RAScrollablePickerView.swift in Sources */,
48D1A6E921160D36007221D1 /* RAScrollablePickerView.swift in Sources */,
6908F4291B500AE500A410E2 /* WindowController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -183,14 +183,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -214,7 +222,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -231,14 +239,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -255,7 +271,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -271,11 +287,12 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
INFOPLIST_FILE = ColorPickerExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "RA.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -286,11 +303,12 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
INFOPLIST_FILE = ColorPickerExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "RA.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ColorPickerExample.xcodeproj">
</FileRef>
</Workspace>
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ColorPickerExample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>6908F4221B500AE500A410E2</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
@@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4371B500AE500A410E2"
BuildableName = "ColorPickerExampleTests.xctest"
BlueprintName = "ColorPickerExampleTests"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4371B500AE500A410E2"
BuildableName = "ColorPickerExampleTests.xctest"
BlueprintName = "ColorPickerExampleTests"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6908F4221B500AE500A410E2"
BuildableName = "ColorPickerExample.app"
BlueprintName = "ColorPickerExample"
ReferencedContainer = "container:ColorPickerExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ColorPickerExample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>6908F4221B500AE500A410E2</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>6908F4371B500AE500A410E2</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
+8
View File
@@ -6,6 +6,7 @@
import UIKit
class ViewController: UIViewController, RAScrollablePickerViewDelegate {
@IBOutlet weak var colorPreView: UIView!
@IBOutlet weak var huePicker: RAScrollablePickerView!
@IBOutlet weak var saturationPicker: RAScrollablePickerView!
@@ -13,15 +14,22 @@ class ViewController: UIViewController, RAScrollablePickerViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let colors: [UIColor] = [.systemBlue, .systemOrange, .systemYellow]
let startColor = colors.randomElement() ?? .systemPink
huePicker.delegate = self
huePicker.set(color: startColor)
saturationPicker.delegate = self
saturationPicker.type = .saturation
saturationPicker.hueValueForPreview = huePicker.value
saturationPicker.set(color: startColor)
brightnessPicker.delegate = self
brightnessPicker.type = .brightness
brightnessPicker.hueValueForPreview = huePicker.value
brightnessPicker.set(color: startColor)
colorPreView.backgroundColor = UIColor(hue: huePicker.value, saturation: saturationPicker.value, brightness: brightnessPicker.value, alpha: 1)
}
+2 -2
View File
@@ -9,8 +9,8 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.
return true
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.io.ackermann.RAScrollablePickerView</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
@@ -1,197 +0,0 @@
// Generated by Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"
#if !defined(__has_include)
# define __has_include(x) 0
#endif
#if !defined(__has_attribute)
# define __has_attribute(x) 0
#endif
#if !defined(__has_feature)
# define __has_feature(x) 0
#endif
#if !defined(__has_warning)
# define __has_warning(x) 0
#endif
#if __has_include(<swift/objc-prologue.h>)
# include <swift/objc-prologue.h>
#endif
#pragma clang diagnostic ignored "-Wauto-import"
#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#if !defined(SWIFT_TYPEDEFS)
# define SWIFT_TYPEDEFS 1
# if __has_include(<uchar.h>)
# include <uchar.h>
# elif !defined(__cplusplus)
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
# endif
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#endif
#if !defined(SWIFT_PASTE)
# define SWIFT_PASTE_HELPER(x, y) x##y
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
#endif
#if !defined(SWIFT_METATYPE)
# define SWIFT_METATYPE(X) Class
#endif
#if !defined(SWIFT_CLASS_PROPERTY)
# if __has_feature(objc_class_property)
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
# else
# define SWIFT_CLASS_PROPERTY(...)
# endif
#endif
#if __has_attribute(objc_runtime_name)
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
#else
# define SWIFT_RUNTIME_NAME(X)
#endif
#if __has_attribute(swift_name)
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
#else
# define SWIFT_COMPILE_NAME(X)
#endif
#if __has_attribute(objc_method_family)
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
#else
# define SWIFT_METHOD_FAMILY(X)
#endif
#if __has_attribute(noescape)
# define SWIFT_NOESCAPE __attribute__((noescape))
#else
# define SWIFT_NOESCAPE
#endif
#if __has_attribute(warn_unused_result)
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
# define SWIFT_WARN_UNUSED_RESULT
#endif
#if __has_attribute(noreturn)
# define SWIFT_NORETURN __attribute__((noreturn))
#else
# define SWIFT_NORETURN
#endif
#if !defined(SWIFT_CLASS_EXTRA)
# define SWIFT_CLASS_EXTRA
#endif
#if !defined(SWIFT_PROTOCOL_EXTRA)
# define SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_ENUM_EXTRA)
# define SWIFT_ENUM_EXTRA
#endif
#if !defined(SWIFT_CLASS)
# if __has_attribute(objc_subclassing_restricted)
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# else
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# endif
#endif
#if !defined(SWIFT_PROTOCOL)
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_EXTENSION)
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
#endif
#if !defined(OBJC_DESIGNATED_INITIALIZER)
# if __has_attribute(objc_designated_initializer)
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
# else
# define OBJC_DESIGNATED_INITIALIZER
# endif
#endif
#if !defined(SWIFT_ENUM_ATTR)
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
# define SWIFT_ENUM_ATTR __attribute__((enum_extensibility(open)))
# else
# define SWIFT_ENUM_ATTR
# endif
#endif
#if !defined(SWIFT_ENUM)
# define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_ATTR SWIFT_ENUM_EXTRA _name : _type
# if __has_feature(generalized_swift_name)
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR SWIFT_ENUM_EXTRA _name : _type
# else
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) SWIFT_ENUM(_type, _name)
# endif
#endif
#if !defined(SWIFT_UNAVAILABLE)
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
#endif
#if !defined(SWIFT_UNAVAILABLE_MSG)
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
#endif
#if !defined(SWIFT_AVAILABILITY)
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
#endif
#if !defined(SWIFT_DEPRECATED)
# define SWIFT_DEPRECATED __attribute__((deprecated))
#endif
#if !defined(SWIFT_DEPRECATED_MSG)
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
#endif
#if __has_feature(attribute_diagnose_if_objc)
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
#else
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
#endif
#if __has_feature(modules)
@import UIKit;
@import CoreGraphics;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
#if __has_warning("-Wpragma-clang-attribute")
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
#endif
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wnullability"
#if __has_attribute(external_source_symbol)
# pragma push_macro("any")
# undef any
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="RAScrollablePickerView",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
# pragma pop_macro("any")
#endif
@class NSCoder;
SWIFT_CLASS("_TtC22RAScrollablePickerView22RAScrollablePickerView")
@interface RAScrollablePickerView : UIView
- (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
- (void)drawRect:(CGRect)rect;
@end
#if __has_attribute(external_source_symbol)
# pragma clang attribute pop
#endif
#pragma clang diagnostic pop
@@ -1,19 +0,0 @@
//
// RAScrollablePickerView.h
// RAScrollablePickerView
//
// Created by Ryan Ackermann on 8/3/18.
// Copyright © 2018 Ryan Ackermann. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for RAScrollablePickerView.
FOUNDATION_EXPORT double RAScrollablePickerViewVersionNumber;
//! Project version string for RAScrollablePickerView.
FOUNDATION_EXPORT const unsigned char RAScrollablePickerViewVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <RAScrollablePickerView/PublicHeader.h>
@@ -1,11 +0,0 @@
framework module RAScrollablePickerView {
umbrella header "RAScrollablePickerView.h"
export *
module * { export * }
}
module RAScrollablePickerView.Swift {
header "RAScrollablePickerView-Swift.h"
requires objc
}
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>RAScrollablePickerView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>48D1A6AB21150558007221D1</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
@@ -29,11 +29,9 @@ public protocol RAScrollablePickerViewDelegate: class {
public class RAScrollablePickerView: UIView {
public var type: PickerType = .hue
public var shouldDecelerate = true
public weak var delegate: RAScrollablePickerViewDelegate?
public var hueValueForPreview: CGFloat = 1.0 {
public var hueValueForPreview: CGFloat = 1 {
didSet {
setNeedsDisplay()
}
@@ -42,7 +40,7 @@ public class RAScrollablePickerView: UIView {
private var lastTouchLocation: CGPoint?
private var decelerateTimer: Timer?
private var decelerationSpeed: CGFloat = 0.0 {
private var decelerationSpeed: CGFloat = 0 {
didSet {
if let timer = decelerateTimer {
if timer.isValid {
@@ -57,31 +55,36 @@ public class RAScrollablePickerView: UIView {
return UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:)))
}()
private(set) var value: CGFloat = 0.5 {
public var value: CGFloat {
return pickerValue
}
private var pickerValue: CGFloat = 0.5 {
didSet {
if type != .hue {
if self.value > 1 {
self.value = 1
if pickerValue > 1 {
pickerValue = 1
}
else if self.value < 0 {
self.value = 0
else if pickerValue < 0 {
pickerValue = 0
}
else {
setNeedsDisplay()
}
}
else {
if self.value > 1 {
self.value -= 1
if pickerValue > 1 {
pickerValue -= 1
}
else if self.value < 0 {
self.value += 1
else if pickerValue < 0 {
pickerValue += 1
}
else {
setNeedsDisplay()
}
}
delegate?.valueChanged(self.value, type: type)
delegate?.valueChanged(pickerValue, type: type)
}
}
@@ -124,7 +127,7 @@ public class RAScrollablePickerView: UIView {
}
}
switch(type) {
switch type {
case .hue:
result.append(UIColor(hue: colorValue, saturation: 1.0, brightness: 1.0, alpha: 1.0).cgColor)
case .saturation:
@@ -137,13 +140,74 @@ public class RAScrollablePickerView: UIView {
return result
}
public var type: PickerType
public var shouldDecelerate: Bool
init(type: PickerType, shouldDecelerate: Bool = true, color: UIColor? = nil) {
self.type = type
self.shouldDecelerate = shouldDecelerate
super.init(frame: .zero)
commonInit()
guard let initialColor = color else {
return
}
set(color: initialColor)
}
public override init(frame: CGRect) {
type = .hue
shouldDecelerate = true
super.init(frame: frame)
commonInit()
}
public required init?(coder aDecoder: NSCoder) {
type = .hue
shouldDecelerate = true
super.init(coder: aDecoder)
commonInit()
}
private func commonInit() {
addGestureRecognizer(panGesture)
layer.cornerRadius = 5.0
clipsToBounds = true
}
public func set(color: UIColor) {
var hue: CGFloat = 0
var brightness: CGFloat = 0
var saturation: CGFloat = 0
color.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: nil)
switch type {
case .hue:
pickerValue = hue
case .saturation:
pickerValue = saturation
case .brightness:
pickerValue = brightness
}
}
@objc private func handlePan(_ gesture: UIPanGestureRecognizer) {
if gesture.state == .began {
lastTouchLocation = gesture.location(in: self)
}
else if gesture.state == .changed {
if let location = lastTouchLocation {
value += (gesture.location(in: self).x - location.x) / frame.width
pickerValue += (gesture.location(in: self).x - location.x) / frame.width
}
lastTouchLocation = gesture.location(in: self)
}
@@ -162,25 +226,9 @@ public class RAScrollablePickerView: UIView {
return
}
value += (decelerationSpeed * 0.025) / 100
pickerValue += (decelerationSpeed * 0.025) / 100
}
private func commonInit() {
addGestureRecognizer(panGesture)
layer.cornerRadius = 5.0
clipsToBounds = true
}
public override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
public override func draw(_ rect: CGRect) {
let ctx = UIGraphicsGetCurrentContext()
+27 -2
View File
@@ -8,8 +8,33 @@
> Lightweight HSB color picker view in Swift.
## Install
### Carthage
Add the following to your Cartfile:
```
github "naturaln0va/RAScrollablePickerView"
```
The build the Cartfile:
```
carthage update --platform iOS
```
Then drag `Carthage/Build/iOS/RAScrollablePickerView.framework` into your Xcode project.
Finally add the import:
```
import RAScrollablePickerView
```
### Manual
Just drop `Framework/RAScrollablePickerView/RAScrollablePickerView/RAScrollablePickerView.swift` in your project.
## Usage
Just drop `RAScrollablePickerView` in your project.
Then create 3 instances of the scrollable picker view and assign each a different type.
``` swift
@@ -46,4 +71,4 @@ func valueChanged(_ value: CGFloat, type: PickerType) {
Feel free the reach out to me if you have an questions.
- https://twitter.com/naturaln0va
- http://ackermann.io
- https://ackermann.io