From 3175860593afcdcd4005f6850c8dbeb7914ac7d9 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 16 Sep 2015 20:35:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=81=9C=E6=AD=A2=E8=8F=8A?= =?UTF-8?q?=E8=8A=B1=E9=A2=9C=E8=89=B2=E7=9A=84=E6=8E=A7=E5=88=B6=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...HPinterestPullRefreshTableViewController.m | 1 + RefreshControl/Manager/XHRefreshControl.m | 1 + RefreshControl/Views/XHLoadMoreView.h | 2 ++ RefreshControl/Views/XHLoadMoreView.m | 15 ++++++++--- RefreshControl/Views/XHPinterestRefreshView.h | 7 +++++ RefreshControl/Views/XHPinterestRefreshView.m | 26 ++++++++++++++++--- .../PinterestDemoRefreshTableViewController.m | 1 + .../XHRefreshControlExample-Info.plist | 2 -- 8 files changed, 47 insertions(+), 8 deletions(-) diff --git a/RefreshControl/Controllers/CustomTableViewController/XHPinterestPullRefreshTableViewController.m b/RefreshControl/Controllers/CustomTableViewController/XHPinterestPullRefreshTableViewController.m index 03b5107..09b8bc3 100644 --- a/RefreshControl/Controllers/CustomTableViewController/XHPinterestPullRefreshTableViewController.m +++ b/RefreshControl/Controllers/CustomTableViewController/XHPinterestPullRefreshTableViewController.m @@ -23,6 +23,7 @@ @implementation XHPinterestPullRefreshTableViewController - (XHPinterestRefreshView *)refreshView { if (!_refreshView) { _refreshView = [[XHPinterestRefreshView alloc] initWithFrame:CGRectMake(0, -50, CGRectGetWidth(self.view.bounds), 50)]; + _refreshView.activityIndicatorColor = self.indicatorColor; } return _refreshView; } diff --git a/RefreshControl/Manager/XHRefreshControl.m b/RefreshControl/Manager/XHRefreshControl.m index 5e6abbd..f49cb32 100644 --- a/RefreshControl/Manager/XHRefreshControl.m +++ b/RefreshControl/Manager/XHRefreshControl.m @@ -371,6 +371,7 @@ - (void)setCircleLineWidth:(CGFloat)circleLineWidth { - (void)setIndicatorColor:(UIColor *)indicatorColor { _indicatorColor = indicatorColor; self.refreshActivityIndicatorContainerView.activityIndicatorView.tintColor = indicatorColor; + self.loadMoreView.activityIndicatorColor = indicatorColor; } #pragma mark - Getter Method diff --git a/RefreshControl/Views/XHLoadMoreView.h b/RefreshControl/Views/XHLoadMoreView.h index d737993..8b375c9 100644 --- a/RefreshControl/Views/XHLoadMoreView.h +++ b/RefreshControl/Views/XHLoadMoreView.h @@ -17,6 +17,8 @@ */ @property (nonatomic, strong) UIButton *loadMoreButton; +@property (nonatomic, strong) UIColor *activityIndicatorColor; + /** * 当外部需要自定义加载更多的按钮时,需要通过该方法进行覆盖原本的按钮 * diff --git a/RefreshControl/Views/XHLoadMoreView.m b/RefreshControl/Views/XHLoadMoreView.m index acda107..ae32dc3 100644 --- a/RefreshControl/Views/XHLoadMoreView.m +++ b/RefreshControl/Views/XHLoadMoreView.m @@ -8,12 +8,14 @@ #import "XHLoadMoreView.h" +#import "XHActivityIndicatorView.h" + @interface XHLoadMoreView () /** * 系统默认菊花控件 */ -@property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView; +@property (nonatomic, strong) XHActivityIndicatorView *activityIndicatorView; /** * 外部定制的提示视图,只有在没有数据的情况下才会出现的 @@ -99,9 +101,16 @@ - (UIButton *)loadMoreButton { return _loadMoreButton; } -- (UIActivityIndicatorView *)activityIndicatorView { +- (void)setActivityIndicatorColor:(UIColor *)activityIndicatorColor { + _activityIndicatorColor = activityIndicatorColor; + self.activityIndicatorView.color = activityIndicatorColor; +} + +- (XHActivityIndicatorView *)activityIndicatorView { if (!_activityIndicatorView) { - _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + _activityIndicatorView = [[XHActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; + _activityIndicatorView.color = [UIColor colorWithRed:228/255.0 green:27 / 255.0 blue:70/255.0 alpha:1.000]; + _activityIndicatorView.indicatorRadius = 6; _activityIndicatorView.hidesWhenStopped = YES; _activityIndicatorView.center = CGPointMake(CGRectGetWidth(self.bounds) / 2.85, CGRectGetHeight(self.bounds) / 2.0); } diff --git a/RefreshControl/Views/XHPinterestRefreshView.h b/RefreshControl/Views/XHPinterestRefreshView.h index e6b6aa9..4030b0a 100644 --- a/RefreshControl/Views/XHPinterestRefreshView.h +++ b/RefreshControl/Views/XHPinterestRefreshView.h @@ -10,8 +10,15 @@ @interface XHPinterestRefreshView : UIView +@property (nonatomic, strong) UIColor *activityIndicatorColor; + @property (nonatomic, assign) CGFloat pullDownOffset; +- (instancetype)initWithFrame:(CGRect)frame + logoImageName:(NSString *)logoImageName + backCircleImageName:(NSString *)backCircleImageName + frontCircleImage:(NSString *)frontCircleImage; + - (void)willStartRefreshing; - (void)didStartRefreshing; diff --git a/RefreshControl/Views/XHPinterestRefreshView.m b/RefreshControl/Views/XHPinterestRefreshView.m index 4037ad8..80ab51b 100644 --- a/RefreshControl/Views/XHPinterestRefreshView.m +++ b/RefreshControl/Views/XHPinterestRefreshView.m @@ -16,13 +16,28 @@ @interface XHPinterestRefreshView () @property (nonatomic, strong) XHActivityIndicatorView *activityIndicatorView; @property (nonatomic, strong) XHCircularProgressView *circularProgressView; +@property (nonatomic, copy) NSString *logoImageName; +@property (nonatomic, copy) NSString *backCircleImageName; +@property (nonatomic, copy) NSString *frontCircleImage; + @end @implementation XHPinterestRefreshView - (instancetype)initWithFrame:(CGRect)frame { + return [self initWithFrame:frame logoImageName:@"bicon" backCircleImageName:@"light_circle" frontCircleImage:@"dark_circle"]; +} + +- (instancetype)initWithFrame:(CGRect)frame + logoImageName:(NSString *)logoImageName + backCircleImageName:(NSString *)backCircleImageName + frontCircleImage:(NSString *)frontCircleImage { self = [super initWithFrame:frame]; if (self) { + self.logoImageName = logoImageName; + self.backCircleImageName = backCircleImageName; + self.frontCircleImage = frontCircleImage; + [self addSubview:self.activityIndicatorView]; [self addSubview:self.circularProgressView]; } @@ -68,6 +83,11 @@ - (void)setPullDownOffset:(CGFloat)pullDownOffset { self.circularProgressView.progress = progress; } +- (void)setActivityIndicatorColor:(UIColor *)activityIndicatorColor { + _activityIndicatorColor = activityIndicatorColor; + self.activityIndicatorView.color = activityIndicatorColor; +} + - (XHActivityIndicatorView *)activityIndicatorView { if (!_activityIndicatorView) { _activityIndicatorView = [[XHActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; @@ -80,9 +100,9 @@ - (XHActivityIndicatorView *)activityIndicatorView { - (XHCircularProgressView *)circularProgressView { if (!_circularProgressView) { - UIImage *logoImage = [UIImage imageNamed:@"bicon.png"]; - UIImage *backCircleImage = [UIImage imageNamed:@"light_circle.png"]; - UIImage *frontCircleImage = [UIImage imageNamed:@"dark_circle.png"]; + UIImage *logoImage = [UIImage imageNamed:self.logoImageName]; + UIImage *backCircleImage = [UIImage imageNamed:self.backCircleImageName]; + UIImage *frontCircleImage = [UIImage imageNamed:self.frontCircleImage]; _circularProgressView = [[XHCircularProgressView alloc] initWithFrame:CGRectMake(0, 0, 25, 25) logo:logoImage diff --git a/XHRefreshControlExample/XHRefreshControlExample/Controllers/PinterestDemoRefreshTableViewController/PinterestDemoRefreshTableViewController.m b/XHRefreshControlExample/XHRefreshControlExample/Controllers/PinterestDemoRefreshTableViewController/PinterestDemoRefreshTableViewController.m index 6ce9fd2..a91b15d 100644 --- a/XHRefreshControlExample/XHRefreshControlExample/Controllers/PinterestDemoRefreshTableViewController/PinterestDemoRefreshTableViewController.m +++ b/XHRefreshControlExample/XHRefreshControlExample/Controllers/PinterestDemoRefreshTableViewController/PinterestDemoRefreshTableViewController.m @@ -19,6 +19,7 @@ - (instancetype)init { self = [super init]; if (self) { //self.pullDownRefreshed = NO; + self.indicatorColor = [UIColor greenColor]; } return self; } diff --git a/XHRefreshControlExample/XHRefreshControlExample/XHRefreshControlExample-Info.plist b/XHRefreshControlExample/XHRefreshControlExample/XHRefreshControlExample-Info.plist index 346d6c2..e959a38 100644 --- a/XHRefreshControlExample/XHRefreshControlExample/XHRefreshControlExample-Info.plist +++ b/XHRefreshControlExample/XHRefreshControlExample/XHRefreshControlExample-Info.plist @@ -24,8 +24,6 @@ 1.0 LSRequiresIPhoneOS - UIMainStoryboardFile~ipad - Main_iPad UIRequiredDeviceCapabilities armv7