|
@@ -10,7 +10,7 @@
|
|
|
#import "MJRefreshHeader.h"
|
|
#import "MJRefreshHeader.h"
|
|
|
|
|
|
|
|
@interface MJRefreshHeader()
|
|
@interface MJRefreshHeader()
|
|
|
-
|
|
|
|
|
|
|
+@property (assign, nonatomic) CGFloat insetTDelta;
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@implementation MJRefreshHeader
|
|
@implementation MJRefreshHeader
|
|
@@ -54,12 +54,19 @@ - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
|
|
|
|
|
|
|
|
// 在刷新的refreshing状态
|
|
// 在刷新的refreshing状态
|
|
|
if (self.state == MJRefreshStateRefreshing) {
|
|
if (self.state == MJRefreshStateRefreshing) {
|
|
|
|
|
+ if (self.window == nil) return;
|
|
|
|
|
+
|
|
|
// sectionheader停留解决
|
|
// sectionheader停留解决
|
|
|
|
|
+ CGFloat insetT = - self.scrollView.mj_offsetY > _scrollViewOriginalInset.top ? - self.scrollView.mj_offsetY : _scrollViewOriginalInset.top;
|
|
|
|
|
+ insetT = insetT > self.mj_h + _scrollViewOriginalInset.top ? self.mj_h + _scrollViewOriginalInset.top : insetT;
|
|
|
|
|
+ self.scrollView.mj_insetT = insetT;
|
|
|
|
|
+
|
|
|
|
|
+ self.insetTDelta = _scrollViewOriginalInset.top - insetT;
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 跳转到下一个控制器时,contentInset可能会变
|
|
// 跳转到下一个控制器时,contentInset可能会变
|
|
|
- _scrollViewOriginalInset = self.scrollView.contentInset;
|
|
|
|
|
|
|
+ _scrollViewOriginalInset = self.scrollView.contentInset;
|
|
|
|
|
|
|
|
// 当前的contentOffset
|
|
// 当前的contentOffset
|
|
|
CGFloat offsetY = self.scrollView.mj_offsetY;
|
|
CGFloat offsetY = self.scrollView.mj_offsetY;
|
|
@@ -105,7 +112,7 @@ - (void)setState:(MJRefreshState)state
|
|
|
|
|
|
|
|
// 恢复inset和offset
|
|
// 恢复inset和offset
|
|
|
[UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{
|
|
[UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{
|
|
|
- self.scrollView.mj_insetT -= self.mj_h;
|
|
|
|
|
|
|
+ self.scrollView.mj_insetT += self.insetTDelta;
|
|
|
|
|
|
|
|
// 自动调整透明度
|
|
// 自动调整透明度
|
|
|
if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0;
|
|
if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0;
|
|
@@ -126,6 +133,13 @@ - (void)setState:(MJRefreshState)state
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)drawRect:(CGRect)rect
|
|
|
|
|
+{
|
|
|
|
|
+ [super drawRect:rect];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
#pragma mark - 公共方法
|
|
#pragma mark - 公共方法
|
|
|
- (void)endRefreshing
|
|
- (void)endRefreshing
|
|
|
{
|
|
{
|