From ed1441e1cfbbda3218e44b7d25d2b2cfb45572c8 Mon Sep 17 00:00:00 2001 From: Hung Nguyen Date: Wed, 25 Sep 2019 15:26:08 +0700 Subject: [PATCH] migration to swift 4.2 --- .../project.pbxproj | 16 ++++++++++------ .../FillableLoaders-Example/ViewController.swift | 12 ++++++------ Source/FillableLoader.swift | 6 +++--- Source/WavesLoader.swift | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Demo/FillableLoaders-Example.xcodeproj/project.pbxproj b/Demo/FillableLoaders-Example.xcodeproj/project.pbxproj index e5ba351..9cc3fca 100644 --- a/Demo/FillableLoaders-Example.xcodeproj/project.pbxproj +++ b/Demo/FillableLoaders-Example.xcodeproj/project.pbxproj @@ -213,11 +213,11 @@ TargetAttributes = { C17B58FC1B9790A800717546 = { CreatedOnToolsVersion = 6.4; - LastSwiftMigration = 0800; + LastSwiftMigration = 1010; }; C1C748921B978FA5001948ED = { CreatedOnToolsVersion = 6.4; - LastSwiftMigration = 0800; + LastSwiftMigration = 1010; }; }; }; @@ -333,7 +333,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -353,7 +354,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -449,7 +451,8 @@ INFOPLIST_FILE = "FillableLoaders-Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -460,7 +463,8 @@ INFOPLIST_FILE = "FillableLoaders-Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Demo/FillableLoaders-Example/ViewController.swift b/Demo/FillableLoaders-Example/ViewController.swift index 5d2fc5c..fbaee6f 100644 --- a/Demo/FillableLoaders-Example/ViewController.swift +++ b/Demo/FillableLoaders-Example/ViewController.swift @@ -49,18 +49,18 @@ class ViewController: UIViewController { button.center = CGPoint(x: view.frame.width/2, y: view.frame.height - 2*margin - 35) button.backgroundColor = UIColor.white button.layer.cornerRadius = 5.0 - button.setTitle("Change Logo", for: UIControlState()) - button.setTitleColor(UIColor.black, for: UIControlState()) + button.setTitle("Change Logo", for: UIControl.State()) + button.setTitleColor(UIColor.black, for: UIControl.State()) button.titleLabel?.font = UIFont.systemFont(ofSize: 14) button.addTarget(self, action: #selector(changeLogo), for: .touchUpInside) window!.addSubview(button) } - func segmentedControlTouch(_ sender: UISegmentedControl) { + @objc func segmentedControlTouch(_ sender: UISegmentedControl) { presentFillableLoader(at: sender.selectedSegmentIndex) } - func changeLogo() { + @objc func changeLogo() { firstLogo = !firstLogo presentFillableLoader(at: segmentedControl.selectedSegmentIndex) } @@ -78,8 +78,8 @@ class ViewController: UIViewController { loader = WavesLoader.showLoader(with: path()) } let window = UIApplication.shared.delegate?.window! - window!.bringSubview(toFront: segmentedControl) - window!.bringSubview(toFront: button) + window!.bringSubviewToFront(segmentedControl) + window!.bringSubviewToFront(button) } func path() -> CGPath{ diff --git a/Source/FillableLoader.swift b/Source/FillableLoader.swift index 3c25c90..a47ea2e 100644 --- a/Source/FillableLoader.swift +++ b/Source/FillableLoader.swift @@ -320,7 +320,7 @@ open class FillableLoader: UIView, CAAnimationDelegate { moveAnimation.values = up ? [loaderView.frame.height/2 + rectSize/2, loaderView.frame.height/2 - rectSize/2 - extraHeight] : [loaderView.frame.height/2 - rectSize/2 - extraHeight, loaderView.frame.height/2 + rectSize/2] moveAnimation.duration = duration moveAnimation.isRemovedOnCompletion = false - moveAnimation.fillMode = kCAFillModeForwards + moveAnimation.fillMode = CAMediaTimingFillMode.forwards moveAnimation.delegate = self moveAnimation.setValue(key, forKey: "animation") shapeLayer.add(moveAnimation, forKey: key) @@ -332,7 +332,7 @@ open class FillableLoader: UIView, CAAnimationDelegate { progressAnimation.values = [oldYPoint, yPoint] progressAnimation.duration = 0.2 progressAnimation.isRemovedOnCompletion = false - progressAnimation.fillMode = kCAFillModeForwards + progressAnimation.fillMode = CAMediaTimingFillMode.forwards shapeLayer.add(progressAnimation, forKey: "progress") oldYPoint = yPoint } @@ -342,7 +342,7 @@ open class FillableLoader: UIView, CAAnimationDelegate { swingAnimation.values = [0, randomAngle(), -randomAngle(), randomAngle(), -randomAngle(), randomAngle(), 0] swingAnimation.duration = 12.0 swingAnimation.isRemovedOnCompletion = false - swingAnimation.fillMode = kCAFillModeForwards + swingAnimation.fillMode = CAMediaTimingFillMode.forwards swingAnimation.delegate = self swingAnimation.setValue("rotation", forKey: "animation") shapeLayer.add(swingAnimation, forKey: "rotation") diff --git a/Source/WavesLoader.swift b/Source/WavesLoader.swift index abd7fe2..bb3ab8d 100644 --- a/Source/WavesLoader.swift +++ b/Source/WavesLoader.swift @@ -35,7 +35,7 @@ open class WavesLoader: FillableLoader { waveAnimation.values = shapesArray(7) waveAnimation.duration = 2.0 waveAnimation.isRemovedOnCompletion = false - waveAnimation.fillMode = kCAFillModeForwards + waveAnimation.fillMode = CAMediaTimingFillMode.forwards waveAnimation.delegate = self waveAnimation.setValue("shape", forKey: "animation") shapeLayer.add(waveAnimation, forKey: "shape")