From 92f7e1bd9624b558ebaf42012640d484af6387fc Mon Sep 17 00:00:00 2001 From: Alexey Ostroverkhov Date: Thu, 27 Jun 2019 16:58:39 +0300 Subject: [PATCH 1/4] update --- .../DGElasticPullToRefreshExtensions.swift | 14 +++++++------- .../DGElasticPullToRefreshLoadingViewCircle.swift | 2 +- .../DGElasticPullToRefreshView.swift | 11 +++++++---- .../project.pbxproj | 8 ++++++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift index ab4f89e..e59f069 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift @@ -99,7 +99,7 @@ public extension UIScrollView { // MARK: - Methods (Public) - public func dg_addPullToRefreshWithActionHandler(_ actionHandler: @escaping () -> Void, loadingView: DGElasticPullToRefreshLoadingView?) { + func dg_addPullToRefreshWithActionHandler(_ actionHandler: @escaping () -> Void, loadingView: DGElasticPullToRefreshLoadingView?) { isMultipleTouchEnabled = false panGestureRecognizer.maximumNumberOfTouches = 1 @@ -112,21 +112,21 @@ public extension UIScrollView { pullToRefreshView.observing = true } - public func dg_removePullToRefresh() { + func dg_removePullToRefresh() { pullToRefreshView?.disassociateDisplayLink() pullToRefreshView?.observing = false pullToRefreshView?.removeFromSuperview() } - public func dg_setPullToRefreshBackgroundColor(_ color: UIColor) { + func dg_setPullToRefreshBackgroundColor(_ color: UIColor) { pullToRefreshView?.backgroundColor = color } - public func dg_setPullToRefreshFillColor(_ color: UIColor) { + func dg_setPullToRefreshFillColor(_ color: UIColor) { pullToRefreshView?.fillColor = color } - public func dg_stopLoading() { + func dg_stopLoading() { pullToRefreshView?.stopLoading() } } @@ -157,8 +157,8 @@ public extension UIPanGestureRecognizer { // MARK: - // MARK: (UIGestureRecognizerState) Extension -public extension UIGestureRecognizerState { - func dg_isAnyOf(_ values: [UIGestureRecognizerState]) -> Bool { +public extension UIGestureRecognizer.State { + func dg_isAnyOf(_ values: [UIGestureRecognizer.State]) -> Bool { return values.contains(where: { $0 == self }) } } diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift index c510baf..5eae828 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift @@ -103,7 +103,7 @@ open class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoadin rotationAnimation.duration = 1.0 rotationAnimation.repeatCount = Float.infinity rotationAnimation.isRemovedOnCompletion = false - rotationAnimation.fillMode = kCAFillModeForwards + rotationAnimation.fillMode = CAMediaTimingFillMode.forwards shapeLayer.add(rotationAnimation, forKey: kRotationAnimation) } diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift index d393eaf..28e3f5c 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift @@ -124,7 +124,7 @@ open class DGElasticPullToRefreshView: UIView { super.init(frame: CGRect.zero) displayLink = CADisplayLink(target: self, selector: #selector(DGElasticPullToRefreshView.displayLinkTick)) - displayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes) + displayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common) displayLink.isPaused = true shapeLayer.backgroundColor = UIColor.clear.cgColor @@ -141,7 +141,10 @@ open class DGElasticPullToRefreshView: UIView { addSubview(r2ControlPointView) addSubview(r3ControlPointView) - NotificationCenter.default.addObserver(self, selector: #selector(DGElasticPullToRefreshView.applicationWillEnterForeground), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil) + NotificationCenter.default.addObserver( + self, + selector: #selector(DGElasticPullToRefreshView.applicationWillEnterForeground), + name: UIApplication.willEnterForegroundNotification, object: nil) } required public init?(coder aDecoder: NSCoder) { @@ -193,7 +196,7 @@ open class DGElasticPullToRefreshView: UIView { // MARK: - // MARK: Notifications - func applicationWillEnterForeground() { + @objc func applicationWillEnterForeground() { if state == .loading { layoutSubviews() } @@ -355,7 +358,7 @@ open class DGElasticPullToRefreshView: UIView { displayLink.isPaused = true } - func displayLinkTick() { + @objc func displayLinkTick() { let width = bounds.width var height: CGFloat = 0.0 diff --git a/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj b/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj index c778cf5..3b44c48 100644 --- a/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj +++ b/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj @@ -118,6 +118,7 @@ TargetAttributes = { 05CD14641BBE8FEA00AF4030 = { CreatedOnToolsVersion = 7.0; + DevelopmentTeam = 5HT442372Z; LastSwiftMigration = 0800; }; }; @@ -127,6 +128,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -269,12 +271,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 5HT442372Z; INFOPLIST_FILE = DGElasticPullToRefreshExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.gatafan.DGElasticPullToRefreshExample; PRODUCT_NAME = DGElasticPullToRefreshExample; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -282,12 +285,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 5HT442372Z; INFOPLIST_FILE = DGElasticPullToRefreshExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.gatafan.DGElasticPullToRefreshExample; PRODUCT_NAME = DGElasticPullToRefreshExample; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; From 61f5b512ac6208c0af557653b12ea13aa60e4b16 Mon Sep 17 00:00:00 2001 From: Alexey Ostroverkhov Date: Thu, 27 Jun 2019 18:21:57 +0300 Subject: [PATCH 2/4] line width 0 --- .../DGElasticPullToRefreshLoadingViewCircle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift index 5eae828..ca9009a 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift @@ -65,7 +65,7 @@ open class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoadin public override init() { super.init(frame: .zero) - shapeLayer.lineWidth = 1.0 + shapeLayer.lineWidth = 0.0 shapeLayer.fillColor = UIColor.clear.cgColor shapeLayer.strokeColor = tintColor.cgColor shapeLayer.actions = ["strokeEnd" : NSNull(), "transform" : NSNull()] From d125893d8dc089ef7e3f21cc6c14779edb24d3aa Mon Sep 17 00:00:00 2001 From: Alexey Ostroverkhov Date: Thu, 27 Jun 2019 18:30:02 +0300 Subject: [PATCH 3/4] fix: height --- .../DGElasticPullToRefreshLoadingViewCircle.swift | 2 +- DGElasticPullToRefresh/DGElasticPullToRefreshView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift index ca9009a..5eae828 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift @@ -65,7 +65,7 @@ open class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoadin public override init() { super.init(frame: .zero) - shapeLayer.lineWidth = 0.0 + shapeLayer.lineWidth = 1.0 shapeLayer.fillColor = UIColor.clear.cgColor shapeLayer.strokeColor = tintColor.cgColor shapeLayer.actions = ["strokeEnd" : NSNull(), "transform" : NSNull()] diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift index 28e3f5c..5f1aef5 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift @@ -370,7 +370,7 @@ open class DGElasticPullToRefreshView: UIView { height = scrollView.contentInset.top - originalContentInsetTop - frame = CGRect(x: 0.0, y: -height - 1.0, width: width, height: height) + frame = CGRect(x: 0.0, y: -height, width: width, height: height) } else if state == .animatingToStopped { height = actualContentOffsetY() } From 69cc827f17a5b16e072e5a404572229c645ed7df Mon Sep 17 00:00:00 2001 From: Alexey Ostroverkhov Date: Thu, 27 Jun 2019 18:34:11 +0300 Subject: [PATCH 4/4] reset --- DGElasticPullToRefresh/DGElasticPullToRefreshView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift index 5f1aef5..2bffe21 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift @@ -370,7 +370,7 @@ open class DGElasticPullToRefreshView: UIView { height = scrollView.contentInset.top - originalContentInsetTop - frame = CGRect(x: 0.0, y: -height, width: width, height: height) + frame = CGRect(x: 0.0, y: -height-1, width: width, height: height) } else if state == .animatingToStopped { height = actualContentOffsetY() }