diff --git a/TGPControls/TGPDiscreteSlider.swift b/TGPControls/TGPDiscreteSlider.swift
index 9ce1a59..a4dd013 100644
--- a/TGPControls/TGPDiscreteSlider.swift
+++ b/TGPControls/TGPDiscreteSlider.swift
@@ -41,7 +41,13 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
}
}
- @IBInspectable public var tickTintColor:UIColor? = nil {
+ @IBInspectable public var minimumTickTintColor:UIColor? = nil {
+ didSet {
+ layoutTrack()
+ }
+ }
+
+ @IBInspectable public var maximumTickTintColor:UIColor? = nil {
didSet {
layoutTrack()
}
@@ -78,7 +84,7 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
}
}
- @IBInspectable public var maximumTrackTintColor:UIColor = UIColor(white: 0.71, alpha: 1) {
+ @IBInspectable public var maximumTrackTintColor = UIColor(white: 0.71, alpha: 1) {
didSet {
layoutTrack()
}
@@ -223,12 +229,19 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
var ticksAbscissae:[CGPoint] = []
var thumbAbscissa:CGFloat = 0
var thumbLayer = CALayer()
+
+ var trackLayer = CALayer()
var leftTrackLayer = CALayer()
var rightTrackLayer = CALayer()
- var trackLayer = CALayer()
var leadingTrackLayer: CALayer!
var trailingTrackLayer: CALayer!
+
var ticksLayer = CALayer()
+ var leftTicksLayer = CALayer()
+ var rightTicksLayer = CALayer()
+ var leadingTicksLayer: CALayer!
+ var trailingTicksLayer: CALayer!
+
var trackRectangle = CGRect.zero
var touchedInside = false
var localeCharacterDirection = CFLocaleLanguageDirection.leftToRight
@@ -275,21 +288,27 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
trailingTrackLayer = (.rightToLeft == localeCharacterDirection)
? leftTrackLayer
: rightTrackLayer
+ leadingTicksLayer = (.rightToLeft == localeCharacterDirection)
+ ? rightTicksLayer
+ : leftTicksLayer
+ trailingTicksLayer = (.rightToLeft == localeCharacterDirection)
+ ? leftTicksLayer
+ : rightTicksLayer
- // Track is a clear clipping layer, and left + right sublayers, which brings in free animation
+ // Track and ticks are in a clear clipping layer, and left + right sublayers,
+ // which brings in free animation
trackLayer.masksToBounds = true
trackLayer.backgroundColor = UIColor.clear.cgColor
layer.addSublayer(trackLayer)
trackLayer.addSublayer(leftTrackLayer)
trackLayer.addSublayer(rightTrackLayer)
- if let backgroundColor = tintColor {
- leadingTrackLayer.backgroundColor = backgroundColor.cgColor
- }
- rightTrackLayer.backgroundColor = maximumTrackTintColor.cgColor
-
// Ticks in between track and thumb
+ ticksLayer.masksToBounds = true
+ ticksLayer.backgroundColor = UIColor.clear.cgColor
layer.addSublayer(ticksLayer)
+ ticksLayer.addSublayer(rightTicksLayer) // reverse order, left covers right
+ ticksLayer.addSublayer(leftTicksLayer)
// The thumb is its own CALayer, which brings in free animation
layer.addSublayer(thumbLayer)
@@ -300,11 +319,6 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
func drawTicks() {
ticksLayer.frame = bounds
-
- if let tickColor = tickTintColor ?? tintColor {
- ticksLayer.backgroundColor = tickColor.cgColor
- }
-
let path = UIBezierPath()
switch tickComponentStyle {
@@ -363,10 +377,35 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
break
}
- let maskLayer = CAShapeLayer()
- maskLayer.frame = trackLayer.bounds
- maskLayer.path = path.cgPath
- ticksLayer.mask = maskLayer
+ leftTicksLayer.frame = {
+ var frame = ticksLayer.bounds
+ let tickWidth = (.rightToLeft == localeCharacterDirection)
+ ? -tickSize.width/2
+ : tickSize.width/2
+ frame.size.width = tickWidth + thumbAbscissa
+
+ return frame
+ }()
+
+ leftTicksLayer.mask = {
+ let maskLayer = CAShapeLayer()
+ maskLayer.frame = ticksLayer.bounds
+ maskLayer.path = path.cgPath
+ return maskLayer
+ }()
+
+ rightTicksLayer.frame = ticksLayer.bounds
+
+ rightTicksLayer.mask = {
+ let maskLayer = CAShapeLayer()
+ maskLayer.path = path.cgPath
+ return maskLayer
+ }()
+
+ if let backgroundColor = minimumTickTintColor ?? (minimumTrackTintColor ?? tintColor) {
+ leadingTicksLayer.backgroundColor = backgroundColor.cgColor
+ }
+ trailingTicksLayer.backgroundColor = maximumTickTintColor?.cgColor ?? maximumTrackTintColor.cgColor
}
func drawTrack() {
diff --git a/TGPControlsDemo/Podfile b/TGPControlsDemo/Podfile
index 2fe7474..ef7a788 100644
--- a/TGPControlsDemo/Podfile
+++ b/TGPControlsDemo/Podfile
@@ -3,8 +3,23 @@ platform :ios, '8.0'
use_frameworks!
target 'TGPControlsDemo-Pods' do
- pod 'TGPControls', :path => '../../TGPControls'
- #pod 'TGPControls'
+ #pod 'TGPControls', :path => '../../TGPControls'
+ pod 'TGPControls'
end
+# Failed to render and update auto layout status for UIViewController : dlopen(Cosmos.framework, 1): no suitable image found
+# https://github.com/CocoaPods/CocoaPods/issues/7606#issuecomment-381279098
+# https://stackoverflow.com/a/49936237/218152
+post_install do |installer|
+ installer.pods_project.targets.each do |target|
+ target.build_configurations.each do |config|
+ config.build_settings.delete('CODE_SIGNING_ALLOWED')
+ config.build_settings.delete('CODE_SIGNING_REQUIRED')
+ end
+ end
+ installer.pods_project.build_configurations.each do |config|
+ config.build_settings.delete('CODE_SIGNING_ALLOWED')
+ config.build_settings.delete('CODE_SIGNING_REQUIRED')
+ end
+end
diff --git a/TGPControlsDemo/TGPControlsDemo.xcodeproj/project.pbxproj b/TGPControlsDemo/TGPControlsDemo.xcodeproj/project.pbxproj
index 793e539..5a4f612 100644
--- a/TGPControlsDemo/TGPControlsDemo.xcodeproj/project.pbxproj
+++ b/TGPControlsDemo/TGPControlsDemo.xcodeproj/project.pbxproj
@@ -164,7 +164,6 @@
DC56BDC01E46DEB900AAD0D9 /* Frameworks */,
DC56BDC11E46DEB900AAD0D9 /* Resources */,
A772C50843047EE677ADAF15 /* [CP] Embed Pods Frameworks */,
- 3FF2E09CAFA7D92A488FACF7 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -258,21 +257,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
- 3FF2E09CAFA7D92A488FACF7 /* [CP] Copy Pods Resources */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "[CP] Copy Pods Resources";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TGPControlsDemo-Pods/Pods-TGPControlsDemo-Pods-resources.sh\"\n";
- showEnvVarsInLog = 0;
- };
A772C50843047EE677ADAF15 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
diff --git a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon1024.png b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon1024.png
index dcfa0ae..1deb8d9 100644
Binary files a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon1024.png and b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon1024.png differ
diff --git a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon120.png b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon120.png
index 974be77..e49557d 100644
Binary files a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon120.png and b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon120.png differ
diff --git a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon152.png b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon152.png
index bfe6952..dadd69f 100644
Binary files a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon152.png and b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon152.png differ
diff --git a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon167.png b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon167.png
index 87313e5..76c223d 100644
Binary files a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon167.png and b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon167.png differ
diff --git a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon76.png b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon76.png
index af9c220..fe11cb9 100644
Binary files a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon76.png and b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/AppIcon.appiconset/icon76.png differ
diff --git a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/launch.imageset/launch1024.png b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/launch.imageset/launch1024.png
index 0264bc2..5fdea49 100644
Binary files a/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/launch.imageset/launch1024.png and b/TGPControlsDemo/TGPControlsDemo/Assets.xcassets/launch.imageset/launch1024.png differ
diff --git a/TGPControlsDemo/TGPControlsDemo/Base.lproj/Main.storyboard b/TGPControlsDemo/TGPControlsDemo/Base.lproj/Main.storyboard
index ce318ba..5e30056 100755
--- a/TGPControlsDemo/TGPControlsDemo/Base.lproj/Main.storyboard
+++ b/TGPControlsDemo/TGPControlsDemo/Base.lproj/Main.storyboard
@@ -379,6 +379,12 @@
+
+
+
+
+
+