Browse Source

Add footer activiryIndicatorStyle

Add footer activiryIndicatorStyle
MJLee 10 years ago
parent
commit
9e15dcfc30

+ 1 - 1
MJRefresh.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name         = "MJRefresh"
-  s.version      = "2.1.0"
+  s.version      = "2.2.0"
   s.summary      = "The easiest way to use pull-to-refresh"
   s.homepage     = "https://github.com/CoderMJLee/MJRefresh"
   s.license      = "MIT"

+ 2 - 1
MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h

@@ -9,5 +9,6 @@
 #import "MJRefreshAutoStateFooter.h"
 
 @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter
-
+/** 菊花的样式 */
+@property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
 @end

+ 16 - 1
MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m

@@ -17,13 +17,28 @@ @implementation MJRefreshAutoNormalFooter
 - (UIActivityIndicatorView *)loadingView
 {
     if (!_loadingView) {
-        UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
+        UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle];
         loadingView.hidesWhenStopped = YES;
         [self addSubview:_loadingView = loadingView];
     }
     return _loadingView;
 }
+
+- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle
+{
+    _activityIndicatorViewStyle = activityIndicatorViewStyle;
+    
+    self.loadingView = nil;
+    [self setNeedsLayout];
+}
 #pragma makr - 重写父类的方法
+- (void)prepare
+{
+    [super prepare];
+    
+    self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
+}
+
 - (void)placeSubviews
 {
     [super placeSubviews];

+ 2 - 0
MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h

@@ -10,4 +10,6 @@
 
 @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter
 @property (weak, nonatomic, readonly) UIImageView *arrowView;
+/** 菊花的样式 */
+@property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
 @end

+ 16 - 1
MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m

@@ -29,13 +29,28 @@ - (UIImageView *)arrowView
 - (UIActivityIndicatorView *)loadingView
 {
     if (!_loadingView) {
-        UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
+        UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle];
         loadingView.hidesWhenStopped = YES;
         [self addSubview:_loadingView = loadingView];
     }
     return _loadingView;
 }
+
+- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle
+{
+    _activityIndicatorViewStyle = activityIndicatorViewStyle;
+    
+    self.loadingView = nil;
+    [self setNeedsLayout];
+}
 #pragma makr - 重写父类的方法
+- (void)prepare
+{
+    [super prepare];
+    
+    self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
+}
+
 - (void)placeSubviews
 {
     [super placeSubviews];

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