Browse Source

add label text setting anytime

M了个J 11 years ago
parent
commit
029054465a

BIN
MJRefreshExample/MJRefreshExample.xcodeproj/project.xcworkspace/xcuserdata/mj.xcuserdatad/UserInterfaceState.xcuserstate


+ 38 - 0
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshBaseView.m

@@ -152,6 +152,41 @@ - (void)endRefreshing
 }
 
 #pragma mark - 设置状态
+- (void)setPullToRefreshText:(NSString *)pullToRefreshText
+{
+    _pullToRefreshText = [pullToRefreshText copy];
+    [self settingLabelText];
+}
+- (void)setReleaseToRefreshText:(NSString *)releaseToRefreshText
+{
+    _releaseToRefreshText = [releaseToRefreshText copy];
+    [self settingLabelText];
+}
+- (void)setRefreshingText:(NSString *)refreshingText
+{
+    _refreshingText = [refreshingText copy];
+    [self settingLabelText];
+}
+- (void)settingLabelText
+{
+	switch (self.state) {
+		case MJRefreshStateNormal:
+            // 设置文字
+            self.statusLabel.text = self.pullToRefreshText;
+			break;
+		case MJRefreshStatePulling:
+            // 设置文字
+            self.statusLabel.text = self.releaseToRefreshText;
+			break;
+        case MJRefreshStateRefreshing:
+            // 设置文字
+            self.statusLabel.text = self.refreshingText;
+			break;
+        default:
+            break;
+	}
+}
+
 - (void)setState:(MJRefreshState)state
 {
     // 0.存储当前的contentInset
@@ -200,5 +235,8 @@ - (void)setState:(MJRefreshState)state
     
     // 3.存储状态
     _state = state;
+    
+    // 4.设置文字
+    [self settingLabelText];
 }
 @end

+ 0 - 9
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshFooterView.m

@@ -133,9 +133,6 @@ - (void)setState:(MJRefreshState)state
     {
 		case MJRefreshStateNormal:
         {
-            // 设置文字
-            self.statusLabel.text = self.pullToRefreshText;
-            
             // 刷新完毕
             if (MJRefreshStateRefreshing == oldState) {
                 self.arrowImage.transform = CGAffineTransformMakeRotation(M_PI);
@@ -160,9 +157,6 @@ - (void)setState:(MJRefreshState)state
             
 		case MJRefreshStatePulling:
         {
-            // 设置文字
-            self.statusLabel.text = self.releaseToRefreshText;
-            
             [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
                 self.arrowImage.transform = CGAffineTransformIdentity;
             }];
@@ -171,9 +165,6 @@ - (void)setState:(MJRefreshState)state
             
         case MJRefreshStateRefreshing:
         {
-            // 设置文字
-            self.statusLabel.text = self.refreshingText;
-            
             // 记录刷新前的数量
             self.lastRefreshCount = [self totalDataCountInScrollView];
             

+ 0 - 8
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshHeaderView.m

@@ -182,9 +182,6 @@ - (void)setState:(MJRefreshState)state
 	switch (state) {
 		case MJRefreshStateNormal: // 下拉可以刷新
         {
-            // 设置文字
-			self.statusLabel.text = self.pullToRefreshText;
-            
             // 刷新完毕
             if (MJRefreshStateRefreshing == oldState) {
                 self.arrowImage.transform = CGAffineTransformIdentity;
@@ -205,8 +202,6 @@ - (void)setState:(MJRefreshState)state
             
 		case MJRefreshStatePulling: // 松开可立即刷新
         {
-            // 设置文字
-            self.statusLabel.text = self.releaseToRefreshText;
             // 执行动画
             [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
                 self.arrowImage.transform = CGAffineTransformMakeRotation(M_PI);
@@ -216,9 +211,6 @@ - (void)setState:(MJRefreshState)state
             
 		case MJRefreshStateRefreshing: // 正在刷新中
         {
-            // 设置文字
-            self.statusLabel.text = self.refreshingText;
-            
             // 执行动画
             [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
                 // 1.增加滚动区域