feat:add SwipeLayout

This commit is contained in:
pengfei.zhou
2019-11-26 21:25:23 +08:00
parent deada07e8d
commit 2fbf4602e8
4 changed files with 39 additions and 24 deletions

View File

@@ -48,6 +48,19 @@ - (void)blend:(NSDictionary *)props {
[super blend:props];
[self blendHeader];
[self blendContent];
dispatch_async(dispatch_get_main_queue(), ^{
[self.view also:^(DoricSwipeRefreshLayout *layout) {
[layout layoutSelf];
[layout.contentView also:^(UIView *it) {
it.x = it.y = 0;
}];
[layout.headerView also:^(UIView *it) {
it.bottom = 0;
it.centerX = layout.width / 2;
}];
layout.contentSize = layout.frame.size;
}];
});
}
- (void)blendContent {

View File

@@ -17,6 +17,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.showsHorizontalScrollIndicator = NO;
self.showsVerticalScrollIndicator = NO;
self.alwaysBounceVertical = YES;
self.delegate = self;
}
return self;
@@ -26,6 +27,7 @@ - (instancetype)init {
if (self = [super init]) {
self.showsHorizontalScrollIndicator = NO;
self.showsVerticalScrollIndicator = NO;
self.alwaysBounceVertical = YES;
self.delegate = self;
}
return self;
@@ -58,16 +60,6 @@ - (void)setHeaderView:(UIView *)headerView {
- (void)layoutSubviews {
[super layoutSubviews];
[self layoutSelf];
[self.contentView also:^(UIView *it) {
[it layoutSubviews];
it.x = it.y = 0;
}];
[self.headerView also:^(UIView *it) {
[it layoutSubviews];
it.bottom = it.centerX = 0;
}];
self.contentSize = self.frame.size;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
@@ -115,4 +107,8 @@ - (void)setRefreshable:(BOOL)refreshable {
- (BOOL)refreshable {
return self.scrollEnabled;
}
- (void)setContentSize:(CGSize)contentSize {
[super setContentSize:contentSize];
}
@end