From a85d22b7cc43c38c96972e6d0538769c371e40ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktoras=20Laukevic=CC=8Cius?= Date: Fri, 24 Nov 2017 09:53:27 +0200 Subject: [PATCH] Introduces defaultSafeArea property to PullToRefreshView --- SSPullToRefresh/SSPullToRefreshView.h | 6 ++++++ SSPullToRefresh/SSPullToRefreshView.m | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/SSPullToRefresh/SSPullToRefreshView.h b/SSPullToRefresh/SSPullToRefreshView.h index 94e8449..8cd6e1b 100644 --- a/SSPullToRefresh/SSPullToRefreshView.h +++ b/SSPullToRefresh/SSPullToRefreshView.h @@ -82,6 +82,12 @@ typedef NS_ENUM(NSUInteger, SSPullToRefreshViewStyle) { */ @property (nonatomic, assign) UIEdgeInsets defaultContentInset; +/** + Safe area of scroll view. + Since iOS11 views have safeAreaInsets `scrollView` `contentOffset` is dependent upon the safe areas. This property is used when calculating current pull state. + */ +@property (nonatomic) UIEdgeInsets defaultSafeArea; + /** The height of the fully expanded content view. The default is `70.0`. diff --git a/SSPullToRefresh/SSPullToRefreshView.m b/SSPullToRefresh/SSPullToRefreshView.m index 24a9cb0..51d950b 100644 --- a/SSPullToRefresh/SSPullToRefreshView.m +++ b/SSPullToRefresh/SSPullToRefreshView.m @@ -30,6 +30,7 @@ @implementation SSPullToRefreshView @synthesize topInset = _topInset; @synthesize animationSemaphore = _animationSemaphore; @synthesize style = _style; +@synthesize defaultSafeArea = _defaultSafeArea; #pragma mark - Accessors @@ -362,7 +363,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } // Get the offset out of the change notification - CGFloat y = [[change objectForKey:NSKeyValueChangeNewKey] CGPointValue].y + self.defaultContentInset.top; + CGFloat y = [[change objectForKey:NSKeyValueChangeNewKey] CGPointValue].y + self.defaultContentInset.top + self.defaultSafeArea.top; // Scroll view is dragging if (self.scrollView.isDragging) {