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];
|
return [super requestFromSubview:subview];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)layoutSubviews {
|
||||||
|
[super layoutSubviews];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)layoutSelf:(CGSize)targetSize {
|
- (void)layoutSelf:(CGSize)targetSize {
|
||||||
if (self.contentOffset.y != 0) {
|
if (self.contentOffset.y != 0) {
|
||||||
return;
|
return;
|
||||||
@ -125,32 +129,15 @@ - (void)setRefreshing:(BOOL)refreshing {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (refreshing) {
|
if (refreshing) {
|
||||||
|
[self setContentOffset:CGPointMake(0, -self.headerView.height) animated:YES];
|
||||||
|
self.scrollEnabled = NO;
|
||||||
if (self.onRefreshBlock) {
|
if (self.onRefreshBlock) {
|
||||||
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 {
|
} else {
|
||||||
self.bounces = YES;
|
[self setContentOffset:(CGPoint) {0, 0} animated: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.scrollEnabled = YES;
|
||||||
}
|
}
|
||||||
];
|
|
||||||
}
|
|
||||||
_refreshing = refreshing;
|
_refreshing = refreshing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user