From 7e5c38e810847b1032ae9cdceadb33a905f7e383 Mon Sep 17 00:00:00 2001 From: huangboju Date: Wed, 19 Sep 2018 14:20:26 +0800 Subject: [PATCH] support swift4.2 --- .../GesturePassword.xcodeproj/project.pbxproj | 12 ++-- .../GesturePassword-Example.xcscheme | 2 +- Example/GesturePassword/AppDelegate.swift | 2 +- .../Controllers/ResetPatternController.swift | 6 +- .../Controllers/SetPatternController.swift | 2 +- .../Controllers/VerifyPatternController.swift | 2 +- GesturePassword/Classes/UIView+Layout.swift | 70 +++++++++---------- .../Classes/Views/LockInfoView.swift | 2 +- GesturePassword/Classes/Views/LockView.swift | 4 +- 9 files changed, 50 insertions(+), 52 deletions(-) diff --git a/Example/GesturePassword.xcodeproj/project.pbxproj b/Example/GesturePassword.xcodeproj/project.pbxproj index 740a7cd..be54d8e 100644 --- a/Example/GesturePassword.xcodeproj/project.pbxproj +++ b/Example/GesturePassword.xcodeproj/project.pbxproj @@ -221,7 +221,7 @@ }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; TestTargetID = 607FACCF1AFB9204008FA782; }; }; @@ -486,7 +486,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = GesturePassword/Bridging.h; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -502,7 +502,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = GesturePassword/Bridging.h; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -522,8 +522,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GesturePassword_Example.app/GesturePassword_Example"; }; name = Debug; @@ -540,8 +539,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GesturePassword_Example.app/GesturePassword_Example"; }; name = Release; diff --git a/Example/GesturePassword.xcodeproj/xcshareddata/xcschemes/GesturePassword-Example.xcscheme b/Example/GesturePassword.xcodeproj/xcshareddata/xcschemes/GesturePassword-Example.xcscheme index 3300aed..8fe921f 100644 --- a/Example/GesturePassword.xcodeproj/xcshareddata/xcschemes/GesturePassword-Example.xcscheme +++ b/Example/GesturePassword.xcodeproj/xcshareddata/xcschemes/GesturePassword-Example.xcscheme @@ -1,6 +1,6 @@ Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/GesturePassword/Classes/Controllers/ResetPatternController.swift b/GesturePassword/Classes/Controllers/ResetPatternController.swift index 1a49058..49afc19 100644 --- a/GesturePassword/Classes/Controllers/ResetPatternController.swift +++ b/GesturePassword/Classes/Controllers/ResetPatternController.swift @@ -20,7 +20,7 @@ public final class ResetPatternController: UIViewController { private var overTimesHandle: ResetPattern? private var forgetHandle: ResetPattern? - override open func viewDidLoad() { + override public func viewDidLoad() { super.viewDidLoad() navigationItem.title = LockCenter.resetPatternTitle @@ -32,10 +32,10 @@ public final class ResetPatternController: UIViewController { func didInitialize() { - addChildViewController(verifyPatternVC) + addChild(verifyPatternVC) view.addSubview(verifyPatternVC.view) verifyPatternVC.view.edgesToSuperview() - verifyPatternVC.didMove(toParentViewController: self) + verifyPatternVC.didMove(toParent: self) navigationItem.title = verifyPatternVC.navigationItem.title diff --git a/GesturePassword/Classes/Controllers/SetPatternController.swift b/GesturePassword/Classes/Controllers/SetPatternController.swift index 5e8ccdb..1df894f 100644 --- a/GesturePassword/Classes/Controllers/SetPatternController.swift +++ b/GesturePassword/Classes/Controllers/SetPatternController.swift @@ -18,7 +18,7 @@ public final class SetPatternController: UIViewController { public var password = "" - override open func viewDidLoad() { + override public func viewDidLoad() { super.viewDidLoad() navigationItem.title = LockCenter.settingTittle diff --git a/GesturePassword/Classes/Controllers/VerifyPatternController.swift b/GesturePassword/Classes/Controllers/VerifyPatternController.swift index c71b6b9..4379e12 100644 --- a/GesturePassword/Classes/Controllers/VerifyPatternController.swift +++ b/GesturePassword/Classes/Controllers/VerifyPatternController.swift @@ -28,7 +28,7 @@ public final class VerifyPatternController: UIViewController { return button }() - override open func viewDidLoad() { + override public func viewDidLoad() { super.viewDidLoad() navigationItem.title = LockCenter.verifyPasswordTitle diff --git a/GesturePassword/Classes/UIView+Layout.swift b/GesturePassword/Classes/UIView+Layout.swift index 4e5406f..7bc3b80 100644 --- a/GesturePassword/Classes/UIView+Layout.swift +++ b/GesturePassword/Classes/UIView+Layout.swift @@ -10,8 +10,8 @@ extension UIView { @discardableResult public func leading(to item: Any?, - attribute: NSLayoutAttribute = .leading, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .leading, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -27,8 +27,8 @@ extension UIView { @discardableResult public func trailing(to item: Any?, - attribute: NSLayoutAttribute = .trailing, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .trailing, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -44,8 +44,8 @@ extension UIView { @discardableResult public func top(to item: Any?, - attribute: NSLayoutAttribute = .top, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .top, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -61,8 +61,8 @@ extension UIView { @discardableResult public func bottom(to item: Any?, - attribute: NSLayoutAttribute = .bottom, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .bottom, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -78,8 +78,8 @@ extension UIView { @discardableResult public func height(to item: Any?, - attribute: NSLayoutAttribute = .height, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .height, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -95,8 +95,8 @@ extension UIView { @discardableResult public func width(to item: Any?, - attribute: NSLayoutAttribute = .width, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .width, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -112,8 +112,8 @@ extension UIView { @discardableResult public func centerY(to item: Any?, - attribute: NSLayoutAttribute = .centerY, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .centerY, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -129,8 +129,8 @@ extension UIView { @discardableResult public func centerX(to item: Any?, - attribute: NSLayoutAttribute = .centerX, - relation: NSLayoutRelation = .equal, + attribute: NSLayoutConstraint.Attribute = .centerX, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -155,7 +155,7 @@ extension UIView { @discardableResult public func edges(to item: Any?, - relation: NSLayoutRelation = .equal, + relation: NSLayoutConstraint.Relation = .equal, insets: UIEdgeInsets = .zero, priority: UILayoutPriority = .required) -> UIView { top(to: item, attribute: .top, relation: relation, constant: insets.top, priority: priority) @@ -165,10 +165,10 @@ extension UIView { return self } - private func prepareLayout(with attr1: NSLayoutAttribute, - relatedBy relation: NSLayoutRelation, + private func prepareLayout(with attr1: NSLayoutConstraint.Attribute, + relatedBy relation: NSLayoutConstraint.Relation, toItem view2: Any?, - attribute attr2: NSLayoutAttribute, + attribute attr2: NSLayoutConstraint.Attribute, multiplier: CGFloat, constant c: CGFloat, priority: UILayoutPriority) { @@ -188,8 +188,8 @@ extension UIView { /// superview extension UIView { @discardableResult - public func topToSuperview(_ attribute: NSLayoutAttribute = .top, - relation: NSLayoutRelation = .equal, + public func topToSuperview(_ attribute: NSLayoutConstraint.Attribute = .top, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -197,8 +197,8 @@ extension UIView { } @discardableResult - public func bottomToSuperview(_ attribute: NSLayoutAttribute = .bottom, - relation: NSLayoutRelation = .equal, + public func bottomToSuperview(_ attribute: NSLayoutConstraint.Attribute = .bottom, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -207,8 +207,8 @@ extension UIView { @discardableResult - public func leadingToSuperview(_ attribute: NSLayoutAttribute = .leading, - relation: NSLayoutRelation = .equal, + public func leadingToSuperview(_ attribute: NSLayoutConstraint.Attribute = .leading, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -216,8 +216,8 @@ extension UIView { } @discardableResult - public func trailingToSuperview(_ attribute: NSLayoutAttribute = .trailing, - relation: NSLayoutRelation = .equal, + public func trailingToSuperview(_ attribute: NSLayoutConstraint.Attribute = .trailing, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -225,8 +225,8 @@ extension UIView { } @discardableResult - public func widthToSuperview(_ attribute: NSLayoutAttribute = .width, - relation: NSLayoutRelation = .equal, + public func widthToSuperview(_ attribute: NSLayoutConstraint.Attribute = .width, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -234,8 +234,8 @@ extension UIView { } @discardableResult - public func heightToSuperview(_ attribute: NSLayoutAttribute = .height, - relation: NSLayoutRelation = .equal, + public func heightToSuperview(_ attribute: NSLayoutConstraint.Attribute = .height, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -249,8 +249,8 @@ extension UIView { } @discardableResult - public func centerXToSuperview(_ attribute: NSLayoutAttribute = .centerX, - relation: NSLayoutRelation = .equal, + public func centerXToSuperview(_ attribute: NSLayoutConstraint.Attribute = .centerX, + relation: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, constant c: CGFloat = 0, priority: UILayoutPriority = .required) -> UIView { @@ -263,7 +263,7 @@ extension UIView { } @discardableResult - public func edgesToSuperview(_ relation: NSLayoutRelation = .equal, + public func edgesToSuperview(_ relation: NSLayoutConstraint.Relation = .equal, insets: UIEdgeInsets = .zero, priority: UILayoutPriority = .required) -> UIView { return edges(to: superview, relation: relation, insets: insets, priority: priority) diff --git a/GesturePassword/Classes/Views/LockInfoView.swift b/GesturePassword/Classes/Views/LockInfoView.swift index 04e93d6..3c2d5f2 100644 --- a/GesturePassword/Classes/Views/LockInfoView.swift +++ b/GesturePassword/Classes/Views/LockInfoView.swift @@ -7,7 +7,7 @@ final class LockInfoView: UIView { private var itemLayers: [LockItemLayer] = [] - open var itemDiameter: CGFloat = 10 { + public var itemDiameter: CGFloat = 10 { didSet { setNeedsLayout() } diff --git a/GesturePassword/Classes/Views/LockView.swift b/GesturePassword/Classes/Views/LockView.swift index 74f096c..ebcab3d 100644 --- a/GesturePassword/Classes/Views/LockView.swift +++ b/GesturePassword/Classes/Views/LockView.swift @@ -52,8 +52,8 @@ open class LockView: UIView { layoutLayers() shapeLayer?.lineWidth = lineWidth - shapeLayer?.lineCap = kCALineCapRound - shapeLayer?.lineJoin = kCALineJoinRound + shapeLayer?.lineCap = .round + shapeLayer?.lineJoin = .round shapeLayer?.fillColor = UIColor.clear.cgColor shapeLayer?.strokeColor = lineColor.cgColor }