CharmingZzz 8 éve
szülő
commit
4e8be61d7c

+ 1 - 1
MJRefresh/Base/MJRefreshBackFooter.m

@@ -31,7 +31,7 @@ - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
     // 如果正在刷新,直接返回
     if (self.state == MJRefreshStateRefreshing) return;
     
-    _scrollViewOriginalInset = self.scrollView.contentInset;
+    _scrollViewOriginalInset = self.scrollView.mj_inset;
     
     // 当前的contentOffset
     CGFloat currentOffsetY = self.scrollView.mj_offsetY;

+ 2 - 2
MJRefresh/Base/MJRefreshComponent.m

@@ -65,7 +65,7 @@ - (void)willMoveToSuperview:(UIView *)newSuperview
         // 设置永远支持垂直弹簧效果
         _scrollView.alwaysBounceVertical = YES;
         // 记录UIScrollView最开始的contentInset
-        _scrollViewOriginalInset = _scrollView.contentInset;
+        _scrollViewOriginalInset = _scrollView.mj_inset;
         
         // 添加监听
         [self addObservers];
@@ -271,4 +271,4 @@ - (CGFloat)mj_textWith {
     }
     return stringWidth;
 }
-@end
+@end

+ 1 - 1
MJRefresh/Base/MJRefreshHeader.m

@@ -66,7 +66,7 @@ - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
     }
     
     // 跳转到下一个控制器时,contentInset可能会变
-     _scrollViewOriginalInset = self.scrollView.contentInset;
+     _scrollViewOriginalInset = self.scrollView.mj_inset;
     
     // 当前的contentOffset
     CGFloat offsetY = self.scrollView.mj_offsetY;

+ 2 - 0
MJRefresh/UIScrollView+MJExtension.h

@@ -10,6 +10,8 @@
 #import <UIKit/UIKit.h>
 
 @interface UIScrollView (MJExtension)
+@property (readonly, nonatomic) UIEdgeInsets mj_inset;
+
 @property (assign, nonatomic) CGFloat mj_insetT;
 @property (assign, nonatomic) CGFloat mj_insetB;
 @property (assign, nonatomic) CGFloat mj_insetL;

+ 22 - 2
MJRefresh/UIScrollView+MJExtension.m

@@ -12,28 +12,48 @@
 
 @implementation UIScrollView (MJExtension)
 
+- (UIEdgeInsets)mj_inset
+{
+#ifdef __IPHONE_11_0
+    if(@available(iOS 11.0, *)){
+        return self.adjustedContentInset;
+    }
+#endif
+    return self.contentInset;
+}
+
 - (void)setMj_insetT:(CGFloat)mj_insetT
 {
     UIEdgeInsets inset = self.contentInset;
     inset.top = mj_insetT;
+#ifdef __IPHONE_11_0
+    if(@available(iOS 11.0, *)){
+        inset.top -= (self.adjustedContentInset.top - self.contentInset.top);
+    }
+#endif
     self.contentInset = inset;
 }
 
 - (CGFloat)mj_insetT
 {
-    return self.contentInset.top;
+    return self.mj_inset.top;
 }
 
 - (void)setMj_insetB:(CGFloat)mj_insetB
 {
     UIEdgeInsets inset = self.contentInset;
     inset.bottom = mj_insetB;
+#ifdef __IPHONE_11_0
+    if(@available(iOS 11.0, *)){
+        inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom);
+    }
+#endif
     self.contentInset = inset;
 }
 
 - (CGFloat)mj_insetB
 {
-    return self.contentInset.bottom;
+    return self.mj_inset.bottom;
 }
 
 - (void)setMj_insetL:(CGFloat)mj_insetL