feat:optimize iOS's swipelayout
This commit is contained in:
parent
eefea8bc2a
commit
06f473e1c6
@ -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,32 +129,15 @@ - (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 setContentOffset:(CGPoint) {0, 0} animated:YES];
|
||||
self.scrollEnabled = YES;
|
||||
}
|
||||
];
|
||||
}
|
||||
_refreshing = refreshing;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user