From fe66cd2b5ff35c7bf086594211c7eb285ea43d49 Mon Sep 17 00:00:00 2001 From: Alexandre Taieb Date: Tue, 8 Jan 2019 16:43:01 -0800 Subject: [PATCH] Swift 4.2 compatibility --- TGPControls.podspec | 2 +- TGPControls/TGPCamelLabels.swift | 24 ++++++++++++------------ TGPControls/TGPDiscreteSlider.swift | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/TGPControls.podspec b/TGPControls.podspec index 29a9862..a57f183 100644 --- a/TGPControls.podspec +++ b/TGPControls.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |spec| # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # spec.name = "TGPControls" - spec.version = "5.1.0" + spec.version = "5.2.0" spec.summary = "Custom animated iOS controls: Animated discrete slider, animated labels" spec.description = <<-DESC diff --git a/TGPControls/TGPCamelLabels.swift b/TGPControls/TGPCamelLabels.swift index d51d7d1..fc906dd 100644 --- a/TGPControls/TGPCamelLabels.swift +++ b/TGPControls/TGPCamelLabels.swift @@ -12,9 +12,9 @@ public class TGPCamelLabels_INTERFACE_BUILDER:UIControl { @IBDesignable public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER { - let validAttributes = [NSLayoutAttribute.top.rawValue, // 3 - NSLayoutAttribute.centerY.rawValue, // 10 - NSLayoutAttribute.bottom.rawValue] // 4 + let validAttributes = [NSLayoutConstraint.Attribute.top.rawValue, // 3 + NSLayoutConstraint.Attribute.centerY.rawValue, // 10 + NSLayoutConstraint.Attribute.bottom.rawValue] // 4 // Only used if labels.count < 1 @IBInspectable public var tickCount:Int { @@ -102,10 +102,10 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER { // Where should emphasized labels be drawn (10: centerY, 3: top, 4: bottom) // By default, emphasized labels are animated towards the top of the frame. // This creates the dock effect (camel). They can also be centered vertically, or move down (reverse effect). - @IBInspectable public var emphasisLayout:Int = NSLayoutAttribute.top.rawValue { + @IBInspectable public var emphasisLayout:Int = NSLayoutConstraint.Attribute.top.rawValue { didSet { if !validAttributes.contains(emphasisLayout) { - emphasisLayout = NSLayoutAttribute.top.rawValue + emphasisLayout = NSLayoutConstraint.Attribute.top.rawValue } layoutTrack() } @@ -114,10 +114,10 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER { // Where should regular labels be drawn (10: centerY, 3: top, 4: bottom) // By default, emphasized labels are animated towards the bottom of the frame. // This creates the dock effect (camel). They can also be centered vertically, or move up (reverse effect). - @IBInspectable public var regularLayout:Int = NSLayoutAttribute.bottom.rawValue { + @IBInspectable public var regularLayout:Int = NSLayoutConstraint.Attribute.bottom.rawValue { didSet { if !validAttributes.contains(regularLayout) { - regularLayout = NSLayoutAttribute.bottom.rawValue + regularLayout = NSLayoutConstraint.Attribute.bottom.rawValue } layoutTrack() } @@ -125,18 +125,18 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER { // MARK: @IBInspectable adapters - public var emphasisLayoutAttribute:NSLayoutAttribute { + public var emphasisLayoutAttribute:NSLayoutConstraint.Attribute { get { - return NSLayoutAttribute(rawValue: emphasisLayout) ?? .top + return NSLayoutConstraint.Attribute(rawValue: emphasisLayout) ?? .top } set { emphasisLayout = newValue.rawValue } } - public var regularLayoutAttribute:NSLayoutAttribute { + public var regularLayoutAttribute:NSLayoutConstraint.Attribute { get { - return NSLayoutAttribute(rawValue: regularLayout) ?? .bottom + return NSLayoutConstraint.Attribute(rawValue: regularLayout) ?? .bottom } set { regularLayout = newValue.rawValue @@ -365,7 +365,7 @@ public class TGPCamelLabels: TGPCamelLabels_INTERFACE_BUILDER { } } - func verticalAlign(aView:UIView, alpha:CGFloat, attribute layout:NSLayoutAttribute) { + func verticalAlign(aView:UIView, alpha:CGFloat, attribute layout:NSLayoutConstraint.Attribute) { switch layout { case .top: aView.frame = { diff --git a/TGPControls/TGPDiscreteSlider.swift b/TGPControls/TGPDiscreteSlider.swift index a4dd013..81e9616 100644 --- a/TGPControls/TGPDiscreteSlider.swift +++ b/TGPControls/TGPDiscreteSlider.swift @@ -752,7 +752,7 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER { return UInt(round( Double(segments) * ratio)) } - func sendActionForControlEvent(controlEvent:UIControlEvents, with event:UIEvent?) { + func sendActionForControlEvent(controlEvent:UIControl.Event, with event:UIEvent?) { for target in allTargets { if let caActions = actions(forTarget: target, forControlEvent: controlEvent) { for actionName in caActions { @@ -767,8 +767,8 @@ public class TGPDiscreteSlider:TGPSlider_INTERFACE_BUILDER { // Interface builder hides the IBInspectable for UIControl let allTargets: Set = Set() - func addTarget(_ target: Any?, action: Selector, for controlEvents: UIControlEvents) {} - func actions(forTarget target: Any?, forControlEvent controlEvent: UIControlEvents) -> [String]? { return nil } + func addTarget(_ target: Any?, action: Selector, for controlEvents: UIControl.Event) {} + func actions(forTarget target: Any?, forControlEvent controlEvent: UIControl.Event) -> [String]? { return nil } func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {} #endif // TARGET_INTERFACE_BUILDER }