From 06f473e1c6bc2d87b8e2cd396e2372bdac757d77 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 3 Dec 2019 11:39:42 +0800 Subject: [PATCH] feat:optimize iOS's swipelayout --- .../Classes/Refresh/DoricSwipeRefreshLayout.m | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/iOS/Pod/Classes/Refresh/DoricSwipeRefreshLayout.m b/iOS/Pod/Classes/Refresh/DoricSwipeRefreshLayout.m index d0dfceec..25def1a5 100644 --- a/iOS/Pod/Classes/Refresh/DoricSwipeRefreshLayout.m +++ b/iOS/Pod/Classes/Refresh/DoricSwipeRefreshLayout.m @@ -68,6 +68,10 @@ - (BOOL)requestFromSubview:(UIView *)subview { return [super requestFromSubview:subview]; } +- (void)layoutSubviews { + [super layoutSubviews]; +} + - (void)layoutSelf:(CGSize)targetSize { if (self.contentOffset.y != 0) { return; @@ -125,31 +129,14 @@ - (void)setRefreshing:(BOOL)refreshing { return; } if (refreshing) { + [self setContentOffset:CGPointMake(0, -self.headerView.height) animated:YES]; + self.scrollEnabled = NO; if (self.onRefreshBlock) { self.onRefreshBlock(); } - [UIView animateWithDuration:.3f - animations:^{ - self.contentOffset = (CGPoint) {0, -self.headerView.height}; - self.contentInset = UIEdgeInsetsMake(self.headerView.height, 0, 0, 0); - } - completion:^(BOOL finished) { - [self.swipePullingDelegate startAnimation]; - self.scrollEnabled = NO; - } - ]; } else { - self.bounces = YES; - [UIView animateWithDuration:.3f - animations:^{ - self.contentOffset = (CGPoint) {0, 0}; - self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); - } - completion:^(BOOL finished) { - [self.swipePullingDelegate stopAnimation]; - self.scrollEnabled = YES; - } - ]; + [self setContentOffset:(CGPoint) {0, 0} animated:YES]; + self.scrollEnabled = YES; } _refreshing = refreshing; }