diff --git a/Classes/Default/RMRPullToRefreshBaseMessageView.swift b/Classes/Default/RMRPullToRefreshBaseMessageView.swift index d24b30a..ea05a16 100755 --- a/Classes/Default/RMRPullToRefreshBaseMessageView.swift +++ b/Classes/Default/RMRPullToRefreshBaseMessageView.swift @@ -39,10 +39,10 @@ class RMRPullToRefreshBaseMessageView: RMRPullToRefreshBaseView { messageView.addSubview(label) label.translatesAutoresizingMaskIntoConstraints = false - for attribute in [NSLayoutAttribute.top, NSLayoutAttribute.right, NSLayoutAttribute.left, NSLayoutAttribute.bottom] { + for attribute in [NSLayoutConstraint.Attribute.top, NSLayoutConstraint.Attribute.right, NSLayoutConstraint.Attribute.left, NSLayoutConstraint.Attribute.bottom] { messageView.addConstraint(NSLayoutConstraint(item: label, attribute: attribute, - relatedBy: NSLayoutRelation.equal, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: messageView, attribute: attribute, multiplier: 1, @@ -58,18 +58,18 @@ class RMRPullToRefreshBaseMessageView: RMRPullToRefreshBaseView { messageView.translatesAutoresizingMaskIntoConstraints = false let heightConstraint = NSLayoutConstraint(item: messageView, - attribute: NSLayoutAttribute.height, - relatedBy: NSLayoutRelation.equal, + attribute: NSLayoutConstraint.Attribute.height, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, - attribute: NSLayoutAttribute.notAnAttribute, + attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 30) let widthConstraint = NSLayoutConstraint(item: messageView, - attribute: NSLayoutAttribute.width, - relatedBy: NSLayoutRelation.equal, + attribute: NSLayoutConstraint.Attribute.width, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, - attribute: NSLayoutAttribute.notAnAttribute, + attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 150) @@ -77,7 +77,7 @@ class RMRPullToRefreshBaseMessageView: RMRPullToRefreshBaseView { let verticalConstraint = NSLayoutConstraint(item: messageView, attribute: .centerY, - relatedBy: NSLayoutRelation.equal, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: .centerY, multiplier: 1, @@ -85,7 +85,7 @@ class RMRPullToRefreshBaseMessageView: RMRPullToRefreshBaseView { let leftConstraint = NSLayoutConstraint(item: messageView, attribute: .left, - relatedBy: NSLayoutRelation.equal, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: .right, multiplier: 1, diff --git a/Classes/Default/RMRPullToRefreshBaseView.swift b/Classes/Default/RMRPullToRefreshBaseView.swift index af3837e..cad3cc8 100755 --- a/Classes/Default/RMRPullToRefreshBaseView.swift +++ b/Classes/Default/RMRPullToRefreshBaseView.swift @@ -45,18 +45,18 @@ class RMRPullToRefreshBaseView: RMRPullToRefreshView { func configureConstraints() { logoImageView.translatesAutoresizingMaskIntoConstraints = false let heightConstraint = NSLayoutConstraint(item: logoImageView, - attribute: NSLayoutAttribute.height, - relatedBy: NSLayoutRelation.equal, + attribute: NSLayoutConstraint.Attribute.height, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, - attribute: NSLayoutAttribute.notAnAttribute, + attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 50) let widthConstraint = NSLayoutConstraint(item: logoImageView, - attribute: NSLayoutAttribute.width, - relatedBy: NSLayoutRelation.equal, + attribute: NSLayoutConstraint.Attribute.width, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, - attribute: NSLayoutAttribute.notAnAttribute, + attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 50) @@ -64,7 +64,7 @@ class RMRPullToRefreshBaseView: RMRPullToRefreshView { let verticalConstraint = NSLayoutConstraint(item: logoImageView, attribute: .centerY, - relatedBy: NSLayoutRelation.equal, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: .centerY, multiplier: 1, @@ -72,7 +72,7 @@ class RMRPullToRefreshBaseView: RMRPullToRefreshView { let horizontalConstraint = NSLayoutConstraint(item: logoImageView, attribute: .centerX, - relatedBy: NSLayoutRelation.equal, + relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: .centerX, multiplier: 1, diff --git a/Classes/RMRPullToRefreshContainerView.swift b/Classes/RMRPullToRefreshContainerView.swift index 81c5f0a..6dcc98c 100755 --- a/Classes/RMRPullToRefreshContainerView.swift +++ b/Classes/RMRPullToRefreshContainerView.swift @@ -25,10 +25,10 @@ open class RMRPullToRefreshContainerView: UIView { if let view = obtainView(state, result: result) { view.translatesAutoresizingMaskIntoConstraints = false addSubview(view) - addConstraint(constraint(self, subview: view, attribute: NSLayoutAttribute.left)) - addConstraint(constraint(self, subview: view, attribute: NSLayoutAttribute.top)) - addConstraint(constraint(self, subview: view, attribute: NSLayoutAttribute.right)) - addConstraint(constraint(self, subview: view, attribute: NSLayoutAttribute.bottom)) + addConstraint(constraint(self, subview: view, attribute: NSLayoutConstraint.Attribute.left)) + addConstraint(constraint(self, subview: view, attribute: NSLayoutConstraint.Attribute.top)) + addConstraint(constraint(self, subview: view, attribute: NSLayoutConstraint.Attribute.right)) + addConstraint(constraint(self, subview: view, attribute: NSLayoutConstraint.Attribute.bottom)) view.layoutIfNeeded() self.currentView = view } @@ -84,7 +84,7 @@ open class RMRPullToRefreshContainerView: UIView { // MARK: - Constraint - func constraint(_ superview: UIView, subview: UIView, attribute: NSLayoutAttribute) -> NSLayoutConstraint { - return NSLayoutConstraint(item: subview, attribute: attribute, relatedBy: NSLayoutRelation.equal, toItem: superview, attribute: attribute, multiplier: 1, constant: 0) + func constraint(_ superview: UIView, subview: UIView, attribute: NSLayoutConstraint.Attribute) -> NSLayoutConstraint { + return NSLayoutConstraint(item: subview, attribute: attribute, relatedBy: NSLayoutConstraint.Relation.equal, toItem: superview, attribute: attribute, multiplier: 1, constant: 0) } } diff --git a/Classes/RMRPullToRefreshController.swift b/Classes/RMRPullToRefreshController.swift index 8d293fa..599b2a7 100644 --- a/Classes/RMRPullToRefreshController.swift +++ b/Classes/RMRPullToRefreshController.swift @@ -230,7 +230,7 @@ open class RMRPullToRefreshController: NSObject { backgroundViewHeightConstraint?.constant = 0 } - private func scrollViewDidChangePanState(_ scrollView: UIScrollView, panState: UIGestureRecognizerState) { + private func scrollViewDidChangePanState(_ scrollView: UIScrollView, panState: UIGestureRecognizer.State) { if panState == .ended || panState == .cancelled || panState == .failed { if state == .loading || (shouldHideWhenStopLoading() && !stopped) { @@ -277,7 +277,7 @@ open class RMRPullToRefreshController: NSObject { if scrollView.contentOffset.y >= 0 { scrollView.contentInset = UIEdgeInsets.zero } else { - scrollView.contentInset = UIEdgeInsetsMake(min(-scrollView.contentOffset.y, originalTopInset+height),0,0,0) + scrollView.contentInset = UIEdgeInsets.init(top: min(-scrollView.contentOffset.y, originalTopInset+height),left: 0,bottom: 0,right: 0) } } @@ -353,7 +353,7 @@ open class RMRPullToRefreshController: NSObject { changingContentInset = true UIView.animate(withDuration: 0.3, delay: 0.0, - options: UIViewAnimationOptions.beginFromCurrentState, + options: UIView.AnimationOptions.beginFromCurrentState, animations: { [weak self]() -> Void in self?.scrollView?.contentInset = contentInset }, completion: { [weak self](finished) -> Void in diff --git a/Example/RMRPullToRefresh/AppDelegate.swift b/Example/RMRPullToRefresh/AppDelegate.swift index c410b83..4655fe4 100644 --- a/Example/RMRPullToRefresh/AppDelegate.swift +++ b/Example/RMRPullToRefresh/AppDelegate.swift @@ -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 } diff --git a/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj b/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj index 18f58c9..adcb369 100644 --- a/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj +++ b/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj @@ -132,7 +132,6 @@ 89CB12311C9DA07B00048E46 /* Frameworks */, 89CB12321C9DA07B00048E46 /* Resources */, 2BE863C51DEA329C1234F1B0 /* [CP] Embed Pods Frameworks */, - C137BE069515EFF1A69455DF /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -229,21 +228,6 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RMRPullToRefreshExample/Pods-RMRPullToRefreshExample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - C137BE069515EFF1A69455DF /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RMRPullToRefreshExample/Pods-RMRPullToRefreshExample-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -389,7 +373,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.redmadrobot.RMRPullToRefresh; PRODUCT_NAME = RMRPullToRefreshExample; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -403,7 +387,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.redmadrobot.RMRPullToRefresh; PRODUCT_NAME = RMRPullToRefreshExample; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; };