diff --git a/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.h b/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.h index 8f7396b..6c8817c 100644 --- a/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.h +++ b/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.h @@ -32,6 +32,21 @@ */ @property (nonatomic, assign) NSInteger requestCurrentPage; +/** + * 是否显示下拉刷新的标签文本,如果返回YES,按照正常排版,如果返回NO,那转圈居中,默认是YES + */ +@property (nonatomic, assign) BOOL hasStatusLabelShowed; + +/** + * 圆圈的颜色,默认是[UIColor colorWithRed:173 / 255.0 green:53 / 255.0 blue:60 / 255.0 alpha:1] + */ +@property (nonatomic, strong) UIColor *circleColor; + +/** + * 圆圈的线条粗细,默认为1, 最大为2 + */ +@property (nonatomic, assign) CGFloat circleLineWidth; + /** * 自动下拉刷新调用的方法,必须放在viewDidAppear方法内,别把这行代码放到别处,然后导致了错误,那就不好了嘛! */ diff --git a/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.m b/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.m index 2020e93..f301066 100644 --- a/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.m +++ b/RefreshControl/Controllers/CustomTableViewController/XHPullRefreshTableViewController.m @@ -45,6 +45,9 @@ - (BOOL)isLoadingDataSource { - (void)setupRefreshControl { if (!_refreshControl) { _refreshControl = [[XHRefreshControl alloc] initWithScrollView:self.tableView delegate:self]; + _refreshControl.hasStatusLabelShowed = self.hasStatusLabelShowed; + _refreshControl.circleColor = self.circleColor; + _refreshControl.circleLineWidth = self.circleLineWidth; } } diff --git a/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.h b/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.h index 2d6cf32..74848ba 100644 --- a/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.h +++ b/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.h @@ -32,6 +32,21 @@ */ @property (nonatomic, assign) NSInteger requestCurrentPage; +/** + * 是否显示下拉刷新的标签文本,如果返回YES,按照正常排版,如果返回NO,那转圈居中,默认是YES + */ +@property (nonatomic, assign) BOOL hasStatusLabelShowed; + +/** + * 圆圈的颜色,默认是[UIColor colorWithRed:173 / 255.0 green:53 / 255.0 blue:60 / 255.0 alpha:1] + */ +@property (nonatomic, strong) UIColor *circleColor; + +/** + * 圆圈的线条粗细,默认为1, 最大为2 + */ +@property (nonatomic, assign) CGFloat circleLineWidth; + /** * 自动下拉刷新调用的方法,必须放在viewDidAppear方法内,别把这行代码放到别处,然后导致了错误,那就不好了嘛! */ diff --git a/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.m b/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.m index f321f74..8080f3c 100644 --- a/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.m +++ b/RefreshControl/Controllers/SystemTableViewController/XHSysatemRefreshTableViewController.m @@ -45,6 +45,9 @@ - (BOOL)isLoadingDataSource { - (void)setupRefreshControl { if (!_customRefreshControl) { _customRefreshControl = [[XHRefreshControl alloc] initWithScrollView:self.tableView delegate:self]; + _customRefreshControl.hasStatusLabelShowed = self.hasStatusLabelShowed; + _customRefreshControl.circleColor = self.circleColor; + _customRefreshControl.circleLineWidth = self.circleLineWidth; } } diff --git a/RefreshControl/Manager/XHRefreshControl.h b/RefreshControl/Manager/XHRefreshControl.h index 3cfabb1..047ea82 100644 --- a/RefreshControl/Manager/XHRefreshControl.h +++ b/RefreshControl/Manager/XHRefreshControl.h @@ -107,11 +107,26 @@ */ - (NSString *)displayAutoLoadMoreRefreshedMessage; - @end @interface XHRefreshControl : NSObject +/** + * 是否显示下拉刷新的标签文本,如果返回YES,按照正常排版,如果返回NO,那转圈居中,默认是YES + */ +@property (nonatomic, assign) BOOL hasStatusLabelShowed; + +/** + * 圆圈的颜色,默认是[UIColor colorWithRed:173 / 255.0 green:53 / 255.0 blue:60 / 255.0 alpha:1] + */ +@property (nonatomic, strong) UIColor *circleColor; + +/** + * 圆圈的线条粗细,默认为1, 最大为2 + */ +@property (nonatomic, assign) CGFloat circleLineWidth; + + - (id)initWithScrollView:(UIScrollView *)scrollView delegate:(id )delegate; /** diff --git a/RefreshControl/Manager/XHRefreshControl.m b/RefreshControl/Manager/XHRefreshControl.m index ba4fb26..9ed9f4f 100644 --- a/RefreshControl/Manager/XHRefreshControl.m +++ b/RefreshControl/Manager/XHRefreshControl.m @@ -305,6 +305,21 @@ - (XHLoadMoreView *)loadMoreView { return _loadMoreView; } +- (void)setHasStatusLabelShowed:(BOOL)hasStatusLabelShowed { + _hasStatusLabelShowed = hasStatusLabelShowed; + self.refreshCircleContainerView.hasStatusLabelShowed = hasStatusLabelShowed; +} + +- (void)setCircleColor:(UIColor *)circleColor { + _circleColor = circleColor; + self.refreshCircleContainerView.circleView.circleColor = circleColor; +} + +- (void)setCircleLineWidth:(CGFloat)circleLineWidth { + _circleLineWidth = circleLineWidth; + self.refreshCircleContainerView.circleView.circleLineWidth = circleLineWidth; +} + #pragma mark - Getter Method - (BOOL)isPullDownRefreshed { @@ -498,6 +513,12 @@ - (void)setup { if (self.isLoadMoreRefreshed) { [self.scrollView addSubview:self.loadMoreView]; } + + self.hasStatusLabelShowed = YES; + + self.circleColor = [UIColor colorWithRed:173 / 255.0 green:53 / 255.0 blue:60 / 255.0 alpha:1]; + + self.circleLineWidth = 1.0; } - (id)initWithScrollView:(UIScrollView *)scrollView delegate:(id )delegate { diff --git a/RefreshControl/Views/XHCircleView.h b/RefreshControl/Views/XHCircleView.h index ce10765..af83a4c 100644 --- a/RefreshControl/Views/XHCircleView.h +++ b/RefreshControl/Views/XHCircleView.h @@ -30,6 +30,16 @@ */ @property (nonatomic, assign) XHRefreshViewLayerType refreshViewLayerType; +/** + * 圆圈的颜色,默认是[UIColor colorWithRed:173 / 255.0 green:53 / 255.0 blue:60 / 255.0 alpha:1] + */ +@property (nonatomic, strong) UIColor *circleColor; + +/** + * 圆圈的线条粗细 + */ +@property (nonatomic, assign) CGFloat circleLineWidth; + /** * 旋转的animation * diff --git a/RefreshControl/Views/XHCircleView.m b/RefreshControl/Views/XHCircleView.m index 7fa487a..1813480 100644 --- a/RefreshControl/Views/XHCircleView.m +++ b/RefreshControl/Views/XHCircleView.m @@ -43,8 +43,8 @@ - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); - CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:173 / 255.0 green:53 / 255.0 blue:60 / 255.0 alpha:1].CGColor); - CGContextSetLineWidth(context, 1.f); + CGContextSetStrokeColorWithColor(context, self.circleColor.CGColor); + CGContextSetLineWidth(context, self.circleLineWidth); static CGFloat radius = 9; if (self.refreshViewLayerType) { diff --git a/RefreshControl/Views/XHRefreshCircleContainerView.h b/RefreshControl/Views/XHRefreshCircleContainerView.h index 9bd08b7..7ead9de 100644 --- a/RefreshControl/Views/XHRefreshCircleContainerView.h +++ b/RefreshControl/Views/XHRefreshCircleContainerView.h @@ -27,4 +27,9 @@ */ @property (nonatomic, strong) UILabel *timeLabel; +/** + * 是否显示下拉刷新的标签文本,如果返回YES,按照正常排版,如果返回NO,那转圈居中 + */ +@property (nonatomic, assign) BOOL hasStatusLabelShowed; + @end diff --git a/RefreshControl/Views/XHRefreshCircleContainerView.m b/RefreshControl/Views/XHRefreshCircleContainerView.m index 770189d..d0cd6dd 100644 --- a/RefreshControl/Views/XHRefreshCircleContainerView.m +++ b/RefreshControl/Views/XHRefreshCircleContainerView.m @@ -16,6 +16,18 @@ @implementation XHRefreshCircleContainerView #pragma mark - Propertys +- (void)setHasStatusLabelShowed:(BOOL)hasStatusLabelShowed { + _hasStatusLabelShowed = hasStatusLabelShowed; + + if (hasStatusLabelShowed) { + self.circleView.frame = CGRectMake((CGRectGetWidth(self.bounds) - kXHRefreshCircleViewHeight) / 2 - 40, (CGRectGetHeight(self.bounds) - kXHRefreshCircleViewHeight) / 2 - 5, kXHRefreshCircleViewHeight, kXHRefreshCircleViewHeight); + } else { + self.circleView.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); + } + self.stateLabel.hidden = !hasStatusLabelShowed; + self.timeLabel.hidden = !hasStatusLabelShowed; +} + - (XHCircleView *)circleView { if (!_circleView) { _circleView = [[XHCircleView alloc] initWithFrame:CGRectMake((CGRectGetWidth(self.bounds) - kXHRefreshCircleViewHeight) / 2 - 40, (CGRectGetHeight(self.bounds) - kXHRefreshCircleViewHeight) / 2 - 5, kXHRefreshCircleViewHeight, kXHRefreshCircleViewHeight)];