Skip to content

Commit

Permalink
support swift4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
huangboju committed Sep 19, 2018
1 parent 0b5eb87 commit 7e5c38e
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 52 deletions.
12 changes: 5 additions & 7 deletions Example/GesturePassword.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Example/GesturePassword/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
70 changes: 35 additions & 35 deletions GesturePassword/Classes/UIView+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -188,17 +188,17 @@ 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 {
return top(to: superview, attribute: attribute, relation: relation, multiplier: multiplier, constant: c, priority: priority)
}

@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 {
Expand All @@ -207,35 +207,35 @@ 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 {
return leading(to: superview, attribute: attribute, relation: relation, multiplier: multiplier, constant: c, priority: priority)
}

@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 {
return trailing(to: superview, attribute: attribute, relation: relation, multiplier: multiplier, constant: c, priority: priority)
}

@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 {
return width(to: superview, attribute: attribute, relation: relation, multiplier: multiplier, constant: c, priority: priority)
}

@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 {
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion GesturePassword/Classes/Views/LockInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class LockInfoView: UIView {

private var itemLayers: [LockItemLayer] = []

open var itemDiameter: CGFloat = 10 {
public var itemDiameter: CGFloat = 10 {
didSet {
setNeedsLayout()
}
Expand Down
4 changes: 2 additions & 2 deletions GesturePassword/Classes/Views/LockView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 7e5c38e

Please sign in to comment.