1- // @file: TGPDiscreteSlider.swift
2- // @project: TGPControls
3- //
4- // @author: Xavier Schott
5- // mailto://xschott@gmail.com
6- // http://thegothicparty.com
7- // tel://+18089383634
8- //
9- // @license: http://opensource.org/licenses/MIT
10- // Copyright (c) 2017, Xavier Schott
11- //
12- // Permission is hereby granted, free of charge, to any person obtaining a copy
13- // of this software and associated documentation files (the "Software"), to deal
14- // in the Software without restriction, including without limitation the rights
15- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16- // copies of the Software, and to permit persons to whom the Software is
17- // furnished to do so, subject to the following conditions:
18- //
19- // The above copyright notice and this permission notice shall be included in
20- // all copies or substantial portions of the Software.
21- //
22- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28- // THE SOFTWARE.
29-
301import UIKit
312
323public enum ComponentStyle : Int {
@@ -37,14 +8,13 @@ public enum ComponentStyle:Int {
378 case image
389}
3910
40-
4111// Interface builder hides the IBInspectable for UIControl
4212#if TARGET_INTERFACE_BUILDER
4313public class TGPSlider_INTERFACE_BUILDER : UIView {
44- }
14+ }
4515#else // !TARGET_INTERFACE_BUILDER
46- public class TGPSlider_INTERFACE_BUILDER : UIControl {
47- }
16+ public class TGPSlider_INTERFACE_BUILDER : UIControl {
17+ }
4818#endif // TARGET_INTERFACE_BUILDER
4919
5020@IBDesignable
@@ -71,6 +41,12 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
7141 }
7242 }
7343
44+ @IBInspectable public var tickTintColor : UIColor ? = nil {
45+ didSet {
46+ layoutTrack ( )
47+ }
48+ }
49+
7450 @IBInspectable public var tickImage : UIImage ? = nil {
7551 didSet {
7652 layoutTrack ( )
@@ -309,8 +285,9 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
309285
310286 func drawTicks( ) {
311287 ticksLayer. frame = bounds
312- if let backgroundColor = tintColor {
313- ticksLayer. backgroundColor = backgroundColor. cgColor
288+
289+ if let tickColor = tickTintColor ?? tintColor {
290+ ticksLayer. backgroundColor = tickColor. cgColor
314291 }
315292
316293 let path = UIBezierPath ( )
@@ -500,10 +477,10 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
500477 // Shadow
501478 if ( shadowRadius != 0.0 ) {
502479 #if TARGET_INTERFACE_BUILDER
503- thumbLayer. shadowOffset = CGSize ( width: shadowOffset. width,
504- height: - shadowOffset. height)
480+ thumbLayer. shadowOffset = CGSize ( width: shadowOffset. width,
481+ height: - shadowOffset. height)
505482 #else // !TARGET_INTERFACE_BUILDER
506- thumbLayer. shadowOffset = shadowOffset
483+ thumbLayer. shadowOffset = shadowOffset
507484 #endif // TARGET_INTERFACE_BUILDER
508485
509486 thumbLayer. shadowRadius = shadowRadius
@@ -585,8 +562,8 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER {
585562 + ( iOSThumbShadowRadius * 2 )
586563 + ( iOSThumbShadowOffset. width * 2 ) ,
587564 height: 28.0
588- + ( iOSThumbShadowRadius * 2 )
589- + ( iOSThumbShadowOffset. height * 2 ) )
565+ + ( iOSThumbShadowRadius * 2 )
566+ + ( iOSThumbShadowOffset. height * 2 ) )
590567
591568 case . image:
592569 if let thumbImage = thumbImage {
0 commit comments