File tree Expand file tree Collapse file tree 8 files changed +105
-50
lines changed
MJRefreshExample.xcodeproj Expand file tree Collapse file tree 8 files changed +105
-50
lines changed Original file line number Diff line number Diff line change 11Pod ::Spec . new do |s |
22 s . name = 'MJRefresh'
3- s . version = '3.1.1 '
3+ s . version = '3.1.3 '
44 s . summary = 'An easy way to use pull-to-refresh'
55 s . homepage = 'https://github.com/CoderMJLee/MJRefresh'
66 s . license = 'MIT'
Original file line number Diff line number Diff line change 1111#import " MJRefreshConst.h"
1212#import " UIView+MJExtension.h"
1313#import " UIScrollView+MJRefresh.h"
14+ #import " NSBundle+MJRefresh.h"
1415
1516@interface MJRefreshComponent ()
1617@property (strong , nonatomic ) UIPanGestureRecognizer *pan;
@@ -149,8 +150,12 @@ - (NSString *)localizedStringForKey:(NSString *)key withDefault:(NSString *)defa
149150 language = [language substringToIndex: range.location];
150151 }
151152
153+ if (language.length == 0 ) {
154+ language = @" zh-Hans" ;
155+ }
156+
152157 // 先从MJRefresh.bundle中查找资源
153- NSBundle *refreshBundle = [NSBundle bundleWithPath: [[ NSBundle mainBundle ] pathForResource: @" MJRefresh " ofType: @" bundle " ] ];
158+ NSBundle *refreshBundle = [NSBundle mj_refreshBundle ];
154159 if ([refreshBundle.localizations containsObject: language]) {
155160 bundle = [NSBundle bundleWithPath: [refreshBundle pathForResource: language ofType: @" lproj" ]];
156161 }
Original file line number Diff line number Diff line change 77//
88
99#import " MJRefreshBackNormalFooter.h"
10+ #import " NSBundle+MJRefresh.h"
1011
1112@interface MJRefreshBackNormalFooter ()
1213{
@@ -20,8 +21,7 @@ @implementation MJRefreshBackNormalFooter
2021- (UIImageView *)arrowView
2122{
2223 if (!_arrowView) {
23- UIImage *image = [UIImage imageNamed: MJRefreshSrcName (@" arrow.png" )] ?: [UIImage imageNamed: MJRefreshFrameworkSrcName (@" arrow.png" )];
24- UIImageView *arrowView = [[UIImageView alloc ] initWithImage: image];
24+ UIImageView *arrowView = [[UIImageView alloc ] initWithImage: [NSBundle mj_arrowImage ]];
2525 [self addSubview: _arrowView = arrowView];
2626 }
2727 return _arrowView;
@@ -75,6 +75,8 @@ - (void)placeSubviews
7575 if (self.loadingView .constraints .count == 0 ) {
7676 self.loadingView .center = arrowCenter;
7777 }
78+
79+ self.arrowView .tintColor = self.stateLabel .textColor ;
7880}
7981
8082- (void )setState : (MJRefreshState)state
Original file line number Diff line number Diff line change 77//
88
99#import " MJRefreshNormalHeader.h"
10+ #import " NSBundle+MJRefresh.h"
1011
1112@interface MJRefreshNormalHeader ()
1213{
@@ -20,9 +21,7 @@ @implementation MJRefreshNormalHeader
2021- (UIImageView *)arrowView
2122{
2223 if (!_arrowView) {
23- UIImage *image = [UIImage imageNamed: MJRefreshSrcName (@" arrow.png" )] ?: [UIImage imageNamed: MJRefreshFrameworkSrcName (@" arrow.png" )];
24- UIImageView *arrowView = [[UIImageView alloc ] initWithImage: [image imageWithRenderingMode: (UIImageRenderingModeAlwaysTemplate)]];
25- arrowView.tintColor = self.stateLabel .textColor ;
24+ UIImageView *arrowView = [[UIImageView alloc ] initWithImage: [NSBundle mj_arrowImage ]];
2625 [self addSubview: _arrowView = arrowView];
2726 }
2827 return _arrowView;
@@ -84,6 +83,8 @@ - (void)placeSubviews
8483 if (self.loadingView .constraints .count == 0 ) {
8584 self.loadingView .center = arrowCenter;
8685 }
86+
87+ self.arrowView .tintColor = self.stateLabel .textColor ;
8788}
8889
8990- (void )setState : (MJRefreshState)state
Original file line number Diff line number Diff line change 2929// 字体大小
3030#define MJRefreshLabelFont [UIFont boldSystemFontOfSize: 14 ]
3131
32- // 图片路径
33- #define MJRefreshSrcName (file ) [@" MJRefresh.bundle" stringByAppendingPathComponent: file]
34- #define MJRefreshFrameworkSrcName (file ) [@" Frameworks/MJRefresh.framework/MJRefresh.bundle" stringByAppendingPathComponent: file]
35-
3632// 常量
3733UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight;
3834UIKIT_EXTERN const CGFloat MJRefreshFooterHeight;
Original file line number Diff line number Diff line change 1+ //
2+ // NSBundle+MJRefresh.h
3+ // MJRefreshExample
4+ //
5+ // Created by MJ Lee on 16/6/13.
6+ // Copyright © 2016年 小码哥. All rights reserved.
7+ //
8+
9+ #import < Foundation/Foundation.h>
10+
11+ @interface NSBundle (MJRefresh)
12+ + (instancetype )mj_refreshBundle ;
13+ + (UIImage *)mj_arrowImage ;
14+ @end
Original file line number Diff line number Diff line change 1+ //
2+ // NSBundle+MJRefresh.m
3+ // MJRefreshExample
4+ //
5+ // Created by MJ Lee on 16/6/13.
6+ // Copyright © 2016年 小码哥. All rights reserved.
7+ //
8+
9+ #import " NSBundle+MJRefresh.h"
10+ #import " MJRefreshComponent.h"
11+
12+ @implementation NSBundle (MJRefresh)
13+ + (instancetype )mj_refreshBundle
14+ {
15+ static NSBundle *refreshBundle = nil ;
16+ if (refreshBundle == nil ) {
17+ // 这里不使用mainBundle是为了适配pod 1.x和0.x
18+ refreshBundle = [NSBundle bundleWithPath: [[NSBundle bundleForClass: [MJRefreshComponent class ]] pathForResource: @" MJRefresh" ofType: @" bundle" ]];
19+ }
20+ return refreshBundle;
21+ }
22+
23+ + (UIImage *)mj_arrowImage
24+ {
25+ static UIImage *arrowImage = nil ;
26+ if (arrowImage == nil ) {
27+ arrowImage = [[UIImage imageWithContentsOfFile: [[self mj_refreshBundle ] pathForResource: @" arrow@2x" ofType: @" png" ]] imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate];
28+ }
29+ return arrowImage;
30+ }
31+ @end
You can’t perform that action at this time.
0 commit comments