Przeglądaj źródła

Add activityIndicatorStyle property

Add activityIndicatorStyle property
MJLee 10 lat temu
rodzic
commit
49c6bbae8f

+ 1 - 1
MJRefresh.podspec

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

+ 2 - 0
MJRefresh/Custom/Header/MJRefreshNormalHeader.h

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

+ 16 - 1
MJRefresh/Custom/Header/MJRefreshNormalHeader.m

@@ -29,15 +29,30 @@ - (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;
 }
 
+#pragma mark - 公共方法
+- (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