Перевел на swift 4.2

This commit is contained in:
Jon Fir 2018-09-20 18:11:23 +07:00
parent 36174af0e8
commit 4abdd96604
6 changed files with 30 additions and 46 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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)
}
}

View File

@ -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

View File

@ -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
}

View File

@ -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;
};