From 8bec4e8e57c9d20953cec6369be3d4c571d0c209 Mon Sep 17 00:00:00 2001 From: Cee Date: Sat, 8 Oct 2016 10:36:49 +0800 Subject: [PATCH] Swift 2.3 support --- PFStepper.podspec | 2 +- PFStepperDemo/Class/PFStepper.swift | 18 +++++++++--------- .../PFStepperDemo.xcodeproj/project.pbxproj | 9 +++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/PFStepper.podspec b/PFStepper.podspec index 3944b35..47e5e00 100644 --- a/PFStepper.podspec +++ b/PFStepper.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "PFStepper" - s.version = "0.0.1" + s.version = "1.0.0" s.summary = "It may be the most elegant stepper you have ever had!" s.homepage = "https://github.com/PerfectFreeze/PFStepper" s.license = { :type => "MIT", :file => "LICENSE" } diff --git a/PFStepperDemo/Class/PFStepper.swift b/PFStepperDemo/Class/PFStepper.swift index d32ce25..b407e19 100644 --- a/PFStepperDemo/Class/PFStepper.swift +++ b/PFStepperDemo/Class/PFStepper.swift @@ -58,9 +58,9 @@ public class PFStepper: UIControl { // button.contentHorizontalAlignment = .Left // button.contentVerticalAlignment = .Top // button.titleEdgeInsets = UIEdgeInsetsMake(10.0, 10.0, 0.0, 0.0) - button.addTarget(self, action: "topButtonTouchDown:", forControlEvents: .TouchDown) - button.addTarget(self, action: "buttonTouchUp:", forControlEvents: UIControlEvents.TouchUpInside) - button.addTarget(self, action: "buttonTouchUp:", forControlEvents: UIControlEvents.TouchUpOutside) + button.addTarget(self, action: #selector(PFStepper.topButtonTouchDown(_:)), forControlEvents: .TouchDown) + button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), forControlEvents: UIControlEvents.TouchUpInside) + button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), forControlEvents: UIControlEvents.TouchUpOutside) return button }() lazy var bottomButton: UIButton = { @@ -69,9 +69,9 @@ public class PFStepper: UIControl { button.setTitleColor(self.buttonsTextColor, forState: .Normal) button.backgroundColor = self.buttonsBackgroundColor button.titleLabel?.font = self.buttonsFont - button.addTarget(self, action: "bottomButtonTouchDown:", forControlEvents: .TouchDown) - button.addTarget(self, action: "buttonTouchUp:", forControlEvents: UIControlEvents.TouchUpInside) - button.addTarget(self, action: "buttonTouchUp:", forControlEvents: UIControlEvents.TouchUpOutside) + button.addTarget(self, action: #selector(PFStepper.bottomButtonTouchDown(_:)), forControlEvents: .TouchDown) + button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), forControlEvents: UIControlEvents.TouchUpInside) + button.addTarget(self, action: #selector(PFStepper.buttonTouchUp(_:)), forControlEvents: UIControlEvents.TouchUpOutside) return button }() @@ -128,7 +128,7 @@ public class PFStepper: UIControl { addSubview(bottomButton) backgroundColor = buttonsBackgroundColor - NSNotificationCenter.defaultCenter().addObserver(self, selector: "reset", name: UIApplicationWillResignActiveNotification, object: nil) + NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(PFStepper.reset), name: UIApplicationWillResignActiveNotification, object: nil) } public override func layoutSubviews() { @@ -201,7 +201,7 @@ extension PFStepper { } func scheduleTimer() { - timer = NSTimer.scheduledTimerWithTimeInterval(timerInterval, target: self, selector: "handleTimerFire:", userInfo: nil, repeats: true) + timer = NSTimer.scheduledTimerWithTimeInterval(timerInterval, target: self, selector: #selector(PFStepper.handleTimerFire(_:)), userInfo: nil, repeats: true) } func resetTimer() { @@ -211,4 +211,4 @@ extension PFStepper { timerFireCount = 0 } } -} \ No newline at end of file +} diff --git a/PFStepperDemo/PFStepperDemo.xcodeproj/project.pbxproj b/PFStepperDemo/PFStepperDemo.xcodeproj/project.pbxproj index 182da88..5619078 100644 --- a/PFStepperDemo/PFStepperDemo.xcodeproj/project.pbxproj +++ b/PFStepperDemo/PFStepperDemo.xcodeproj/project.pbxproj @@ -204,13 +204,16 @@ TargetAttributes = { 92165C8E1C2A67A500274852 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; }; 92165CA21C2A67A500274852 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; TestTargetID = 92165C8E1C2A67A500274852; }; 92165CAD1C2A67A500274852 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; TestTargetID = 92165C8E1C2A67A500274852; }; }; @@ -413,6 +416,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemo; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; }; name = Debug; }; @@ -424,6 +428,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemo; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; }; name = Release; }; @@ -435,6 +440,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PFStepperDemo.app/PFStepperDemo"; }; name = Debug; @@ -447,6 +453,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PFStepperDemo.app/PFStepperDemo"; }; name = Release; @@ -458,6 +465,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; TEST_TARGET_NAME = PFStepperDemo; USES_XCTRUNNER = YES; }; @@ -470,6 +478,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = io.Cee.PFStepperDemoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; TEST_TARGET_NAME = PFStepperDemo; USES_XCTRUNNER = YES; };