From 5f027e6d7ae3ce8320bc47a86530322a2150ef42 Mon Sep 17 00:00:00 2001 From: xoyip Date: Wed, 26 Feb 2014 17:35:38 +0900 Subject: [PATCH] Custom text for refresh view. --- .../MNMBottomPullToRefreshManager.h | 7 +++++ .../MNMBottomPullToRefreshManager.m | 26 +++++++++++++++++++ .../MNMBottomPullToRefreshView.h | 7 +++++ .../MNMBottomPullToRefreshView.m | 15 ++++++++--- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.h b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.h index bdcd140..f8a7440 100644 --- a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.h +++ b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.h @@ -106,4 +106,11 @@ */ - (void)tableViewReloadFinished; +/** + * Custom text for refresh view. + */ +@property (nonatomic, weak) NSString *pullText; +@property (nonatomic, weak) NSString *releaseText; +@property (nonatomic, weak) NSString *loadingText; + @end diff --git a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.m b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.m index 81f61c4..04e7500 100644 --- a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.m +++ b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshManager.m @@ -200,4 +200,30 @@ - (void)tableViewReloadFinished { [pullToRefreshView_ changeStateOfControl:MNMBottomPullToRefreshViewStateIdle offset:CGFLOAT_MAX]; } +#pragma mark - +#pragma mark properties +- (void)setPullText:(NSString *)pullText { + pullToRefreshView_.pullText = pullText; +} + +- (void)setReleaseText:(NSString *)releaseText { + pullToRefreshView_.releaseText = releaseText; +} + +- (void)setLoadingText:(NSString *)loadingText { + pullToRefreshView_.loadingText = loadingText; +} + +- (NSString *)pullText { + return pullToRefreshView_.pullText; +} + +- (NSString *)releaseText { + return pullToRefreshView_.releaseText; +} + +- (NSString *)loadingText { + return pullToRefreshView_.loadingText; +} + @end \ No newline at end of file diff --git a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.h b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.h index d814170..8d44ae0 100644 --- a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.h +++ b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.h @@ -50,6 +50,13 @@ typedef enum { */ @property (nonatomic, readonly) CGFloat fixedHeight; +/** + * Custom text for refresh view. + */ +@property (nonatomic, weak) NSString *pullText; +@property (nonatomic, weak) NSString *releaseText; +@property (nonatomic, weak) NSString *loadingText; + /** * Changes the state of the control depending on state value. * diff --git a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.m b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.m index 92b986e..80bcede 100644 --- a/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.m +++ b/MNMBottomPullToRefreshDemo/MNMBottomPullToRefresh/MNMBottomPullToRefreshView.m @@ -84,6 +84,9 @@ @implementation MNMBottomPullToRefreshView @synthesize rotateIconWhileBecomingVisible = rotateIconWhileBecomingVisible_; @dynamic isLoading; @synthesize fixedHeight = fixedHeight_; +@synthesize pullText = pullText_; +@synthesize releaseText = releaseText_; +@synthesize loadingText = loadingText_; #pragma mark - #pragma mark Initialization @@ -137,6 +140,10 @@ - (id)initWithFrame:(CGRect)frame { fixedHeight_ = CGRectGetHeight(frame); rotateIconWhileBecomingVisible_ = YES; + pullText_ = MNM_BOTTOM_PTR_PULL_TEXT_KEY; + releaseText_ = MNM_BOTTOM_PTR_RELEASE_TEXT_KEY; + loadingText_ = MNM_BOTTOM_PTR_LOADING_TEXT_KEY; + [self changeStateOfControl:MNMBottomPullToRefreshViewStateIdle offset:CGFLOAT_MAX]; } @@ -182,7 +189,7 @@ - (void)changeStateOfControl:(MNMBottomPullToRefreshViewState)state offset:(CGFl [loadingActivityIndicator_ stopAnimating]; - [messageLabel_ setText:MNM_BOTTOM_PTR_PULL_TEXT_KEY]; + [messageLabel_ setText:pullText_]; break; @@ -199,7 +206,7 @@ - (void)changeStateOfControl:(MNMBottomPullToRefreshViewState)state offset:(CGFl [iconImageView_ setTransform:CGAffineTransformIdentity]; } - [messageLabel_ setText:MNM_BOTTOM_PTR_PULL_TEXT_KEY]; + [messageLabel_ setText:pullText_]; break; @@ -207,7 +214,7 @@ - (void)changeStateOfControl:(MNMBottomPullToRefreshViewState)state offset:(CGFl [iconImageView_ setTransform:CGAffineTransformMakeRotation(M_PI)]; - [messageLabel_ setText:MNM_BOTTOM_PTR_RELEASE_TEXT_KEY]; + [messageLabel_ setText:releaseText_]; height = fixedHeight_ + fabs(offset); @@ -219,7 +226,7 @@ - (void)changeStateOfControl:(MNMBottomPullToRefreshViewState)state offset:(CGFl [loadingActivityIndicator_ startAnimating]; - [messageLabel_ setText:MNM_BOTTOM_PTR_LOADING_TEXT_KEY]; + [messageLabel_ setText:loadingText_]; height = fixedHeight_ + fabs(offset);