From 1f73117f7f8a7afd8dd2307153a24785b18a53d7 Mon Sep 17 00:00:00 2001 From: Sean Zehnder Date: Thu, 20 Sep 2018 17:41:37 -0400 Subject: [PATCH] fixes for swift4.2 --- TGPControls.xcodeproj/project.pbxproj | 4 ++-- TGPControls/TGPCamelLabels.swift | 24 ++++++++++++------------ TGPControls/TGPDiscreteSlider.swift | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/TGPControls.xcodeproj/project.pbxproj b/TGPControls.xcodeproj/project.pbxproj index 065ddcc..84807b6 100644 --- a/TGPControls.xcodeproj/project.pbxproj +++ b/TGPControls.xcodeproj/project.pbxproj @@ -288,7 +288,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -313,7 +313,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; 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..31583f5 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 {