├── .gitignore
├── CoolNaviDemo.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── ian.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── ian.xcuserdatad
│ └── xcschemes
│ ├── CoolNaviDemo.xcscheme
│ └── xcschememanagement.plist
├── CoolNaviDemo.xcworkspace
├── contents.xcworkspacedata
└── xcuserdata
│ └── ian.xcuserdatad
│ └── UserInterfaceState.xcuserstate
├── CoolNaviDemo
├── .Podfile.swp
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ └── LaunchScreen.xib
├── CoolNavi
│ ├── CoolNavi.h
│ └── CoolNavi.m
├── CoolNaviViewController.h
├── CoolNaviViewController.m
├── Default-568h@2x.png
├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── background.imageset
│ │ ├── Contents.json
│ │ ├── background@2x.png
│ │ └── background@3x.png
├── Info.plist
├── ViewController.h
├── ViewController.m
└── main.m
├── CoolNaviDemoTests
├── CoolNaviDemoTests.m
└── Info.plist
├── Demo.gif
├── LICENSE
├── Podfile
├── Podfile.lock
├── Pods
├── Headers
│ ├── Build
│ │ └── SDWebImage
│ │ │ ├── NSData+ImageContentType.h
│ │ │ ├── SDImageCache.h
│ │ │ ├── SDWebImageCompat.h
│ │ │ ├── SDWebImageDecoder.h
│ │ │ ├── SDWebImageDownloader.h
│ │ │ ├── SDWebImageDownloaderOperation.h
│ │ │ ├── SDWebImageManager.h
│ │ │ ├── SDWebImageOperation.h
│ │ │ ├── SDWebImagePrefetcher.h
│ │ │ ├── UIButton+WebCache.h
│ │ │ ├── UIImage+GIF.h
│ │ │ ├── UIImage+MultiFormat.h
│ │ │ ├── UIImageView+HighlightedWebCache.h
│ │ │ ├── UIImageView+WebCache.h
│ │ │ └── UIView+WebCacheOperation.h
│ └── Public
│ │ └── SDWebImage
│ │ ├── NSData+ImageContentType.h
│ │ ├── SDImageCache.h
│ │ ├── SDWebImageCompat.h
│ │ ├── SDWebImageDecoder.h
│ │ ├── SDWebImageDownloader.h
│ │ ├── SDWebImageDownloaderOperation.h
│ │ ├── SDWebImageManager.h
│ │ ├── SDWebImageOperation.h
│ │ ├── SDWebImagePrefetcher.h
│ │ ├── UIButton+WebCache.h
│ │ ├── UIImage+GIF.h
│ │ ├── UIImage+MultiFormat.h
│ │ ├── UIImageView+HighlightedWebCache.h
│ │ ├── UIImageView+WebCache.h
│ │ └── UIView+WebCacheOperation.h
├── Manifest.lock
├── Pods.xcodeproj
│ ├── project.pbxproj
│ └── xcuserdata
│ │ └── ian.xcuserdatad
│ │ └── xcschemes
│ │ ├── Pods-SDWebImage.xcscheme
│ │ ├── Pods.xcscheme
│ │ └── xcschememanagement.plist
├── SDWebImage
│ ├── LICENSE
│ ├── README.md
│ └── SDWebImage
│ │ ├── NSData+ImageContentType.h
│ │ ├── NSData+ImageContentType.m
│ │ ├── SDImageCache.h
│ │ ├── SDImageCache.m
│ │ ├── SDWebImageCompat.h
│ │ ├── SDWebImageCompat.m
│ │ ├── SDWebImageDecoder.h
│ │ ├── SDWebImageDecoder.m
│ │ ├── SDWebImageDownloader.h
│ │ ├── SDWebImageDownloader.m
│ │ ├── SDWebImageDownloaderOperation.h
│ │ ├── SDWebImageDownloaderOperation.m
│ │ ├── SDWebImageManager.h
│ │ ├── SDWebImageManager.m
│ │ ├── SDWebImageOperation.h
│ │ ├── SDWebImagePrefetcher.h
│ │ ├── SDWebImagePrefetcher.m
│ │ ├── UIButton+WebCache.h
│ │ ├── UIButton+WebCache.m
│ │ ├── UIImage+GIF.h
│ │ ├── UIImage+GIF.m
│ │ ├── UIImage+MultiFormat.h
│ │ ├── UIImage+MultiFormat.m
│ │ ├── UIImageView+HighlightedWebCache.h
│ │ ├── UIImageView+HighlightedWebCache.m
│ │ ├── UIImageView+WebCache.h
│ │ ├── UIImageView+WebCache.m
│ │ ├── UIView+WebCacheOperation.h
│ │ └── UIView+WebCacheOperation.m
└── Target Support Files
│ ├── Pods-SDWebImage
│ ├── Pods-SDWebImage-Private.xcconfig
│ ├── Pods-SDWebImage-dummy.m
│ ├── Pods-SDWebImage-prefix.pch
│ └── Pods-SDWebImage.xcconfig
│ └── Pods
│ ├── Pods-acknowledgements.markdown
│ ├── Pods-acknowledgements.plist
│ ├── Pods-dummy.m
│ ├── Pods-environment.h
│ ├── Pods-resources.sh
│ ├── Pods.debug.xcconfig
│ └── Pods.release.xcconfig
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | # Pods/
27 |
--------------------------------------------------------------------------------
/CoolNaviDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CoolNaviDemo.xcodeproj/project.xcworkspace/xcuserdata/ian.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianisme/CoolNavi/0ee77be82a53e087854f7011596831dfbfc50fb1/CoolNaviDemo.xcodeproj/project.xcworkspace/xcuserdata/ian.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CoolNaviDemo.xcodeproj/xcuserdata/ian.xcuserdatad/xcschemes/CoolNaviDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
100 |
101 |
102 |
103 |
105 |
106 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/CoolNaviDemo.xcodeproj/xcuserdata/ian.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CoolNaviDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 3CB0AA2F1A6D03C200135B22
16 |
17 | primary
18 |
19 |
20 | 3CB0AA481A6D03C300135B22
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CoolNaviDemo.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/CoolNaviDemo.xcworkspace/xcuserdata/ian.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianisme/CoolNavi/0ee77be82a53e087854f7011596831dfbfc50fb1/CoolNaviDemo.xcworkspace/xcuserdata/ian.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CoolNaviDemo/.Podfile.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianisme/CoolNavi/0ee77be82a53e087854f7011596831dfbfc50fb1/CoolNaviDemo/.Podfile.swp
--------------------------------------------------------------------------------
/CoolNaviDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/CoolNaviDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "ViewController.h"
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
20 | self.window.backgroundColor = [UIColor whiteColor];
21 | [self.window makeKeyAndVisible];
22 |
23 | ViewController *tableVC = [[ViewController alloc] init];
24 | self.window.rootViewController = tableVC;
25 | return YES;
26 | }
27 |
28 | - (void)applicationWillResignActive:(UIApplication *)application {
29 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
30 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
31 | }
32 |
33 | - (void)applicationDidEnterBackground:(UIApplication *)application {
34 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
35 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
36 | }
37 |
38 | - (void)applicationWillEnterForeground:(UIApplication *)application {
39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
40 | }
41 |
42 | - (void)applicationDidBecomeActive:(UIApplication *)application {
43 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
44 | }
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/CoolNaviDemo/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/CoolNaviDemo/CoolNavi/CoolNavi.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoolNavi.h
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoolNavi : UIView
12 |
13 | @property (nonatomic, weak) UIScrollView *scrollView;
14 | // image action
15 | @property (nonatomic, copy) void(^imgActionBlock)();
16 |
17 | - (id)initWithFrame:(CGRect)frame backGroudImage:(NSString *)backImageName headerImageURL:(NSString *)headerImageURL title:(NSString *)title subTitle:(NSString *)subTitle;
18 |
19 | -(void)updateSubViewsWithScrollOffset:(CGPoint)newOffset;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/CoolNaviDemo/CoolNavi/CoolNavi.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoolNavi.m
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import "CoolNavi.h"
10 | #import "UIImageView+WebCache.h"
11 | @interface CoolNavi()
12 |
13 | @property (nonatomic, strong) UIImageView *backImageView;
14 | @property (nonatomic, strong) UIImageView *headerImageView;
15 | @property (nonatomic, strong) UILabel *titleLabel;
16 | @property (nonatomic, strong) UILabel *subTitleLabel;
17 | @property (nonatomic, assign) CGPoint prePoint;
18 |
19 | @end
20 |
21 |
22 | @implementation CoolNavi
23 |
24 | - (id)initWithFrame:(CGRect)frame backGroudImage:(NSString *)backImageName headerImageURL:(NSString *)headerImageURL title:(NSString *)title subTitle:(NSString *)subTitle
25 | {
26 | self = [super initWithFrame:frame];
27 | if (self) {
28 | self.backgroundColor = [UIColor clearColor];
29 |
30 | _backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, -0.5*frame.size.height, frame.size.width, frame.size.height*1.5)];
31 |
32 | _backImageView.image = [UIImage imageNamed:backImageName];
33 | _backImageView.contentMode = UIViewContentModeScaleAspectFill;
34 |
35 | _headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width*0.5-70*0.5, 0.27*frame.size.height, 70, 70)];
36 | [_headerImageView sd_setImageWithURL:[NSURL URLWithString:headerImageURL]];
37 | [_headerImageView.layer setMasksToBounds:YES];
38 | _headerImageView.layer.cornerRadius = _headerImageView.frame.size.width/2.0f;
39 | _headerImageView.userInteractionEnabled = YES;
40 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
41 | [_headerImageView addGestureRecognizer:tap];
42 |
43 | _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0.6*frame.size.height, frame.size.width, frame.size.height*0.2)];
44 | _titleLabel.textAlignment = NSTextAlignmentCenter;
45 | _titleLabel.font = [UIFont systemFontOfSize:14];
46 | _titleLabel.text = title;
47 |
48 | _subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0.75*frame.size.height, frame.size.width, frame.size.height*0.1)];
49 | _subTitleLabel.textAlignment = NSTextAlignmentCenter;
50 | _subTitleLabel.font = [UIFont systemFontOfSize:12];
51 | _subTitleLabel.text = subTitle;
52 | _titleLabel.textColor = [UIColor whiteColor];
53 | _subTitleLabel.textColor = [UIColor whiteColor];
54 |
55 |
56 | [self addSubview:_backImageView];
57 | [self addSubview:_headerImageView];
58 | [self addSubview:_titleLabel];
59 | [self addSubview:_subTitleLabel];
60 | self.clipsToBounds = YES;
61 |
62 | }
63 | return self;
64 |
65 | }
66 |
67 | - (void)dealloc
68 | {
69 | [self.scrollView removeObserver:self forKeyPath:@"contentOffset"];
70 | }
71 |
72 | -(void)willMoveToSuperview:(UIView *)newSuperview
73 | {
74 | [self.scrollView addObserver:self forKeyPath:@"contentOffset" options:(NSKeyValueObservingOptionNew) context:Nil];
75 | self.scrollView.contentInset = UIEdgeInsetsMake(self.frame.size.height, 0 ,0 , 0);
76 | self.scrollView.scrollIndicatorInsets = self.scrollView.contentInset;
77 | }
78 |
79 |
80 |
81 | -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
82 | {
83 | CGPoint newOffset = [change[@"new"] CGPointValue];
84 | [self updateSubViewsWithScrollOffset:newOffset];
85 | }
86 |
87 | -(void)updateSubViewsWithScrollOffset:(CGPoint)newOffset
88 | {
89 |
90 | CGFloat destinaOffset = -64;
91 | CGFloat startChangeOffset = -self.scrollView.contentInset.top;
92 | newOffset = CGPointMake(newOffset.x, newOffset.ydestinaOffset?destinaOffset:newOffset.y));
93 |
94 | CGFloat subviewOffset = self.frame.size.height-40; // 子视图的偏移量
95 | CGFloat newY = -newOffset.y-self.scrollView.contentInset.top;
96 | CGFloat d = destinaOffset-startChangeOffset;
97 | CGFloat alpha = 1-(newOffset.y-startChangeOffset)/d;
98 | CGFloat imageReduce = 1-(newOffset.y-startChangeOffset)/(d*2);
99 | self.subTitleLabel.alpha = alpha;
100 | self.titleLabel.alpha = alpha;
101 | self.frame = CGRectMake(0, newY, self.frame.size.width, self.frame.size.height);
102 | self.backImageView.frame = CGRectMake(0, -0.5*self.frame.size.height+(1.5*self.frame.size.height-64)*(1-alpha), self.backImageView.frame.size.width, self.backImageView.frame.size.height);
103 |
104 | CGAffineTransform t = CGAffineTransformMakeTranslation(0,(subviewOffset-0.35*self.frame.size.height)*(1-alpha));
105 | _headerImageView.transform = CGAffineTransformScale(t,
106 | imageReduce, imageReduce);
107 |
108 | self.titleLabel.frame = CGRectMake(0, 0.6*self.frame.size.height+(subviewOffset-0.45*self.frame.size.height)*(1-alpha), self.frame.size.width, self.frame.size.height*0.2);
109 | self.subTitleLabel.frame = CGRectMake(0, 0.75*self.frame.size.height+(subviewOffset-0.45*self.frame.size.height)*(1-alpha), self.frame.size.width, self.frame.size.height*0.1);
110 | }
111 |
112 | - (void)tapAction:(id)sender
113 | {
114 | if (self.imgActionBlock) {
115 | self.imgActionBlock();
116 | }
117 | }
118 |
119 |
120 |
121 | @end
122 |
--------------------------------------------------------------------------------
/CoolNaviDemo/CoolNaviViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoolNaviViewController.h
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/9/12.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoolNaviViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CoolNaviDemo/CoolNaviViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoolNaviViewController.m
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/9/12.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 | #define kWindowHeight 205.0f
9 | #import "CoolNaviViewController.h"
10 | #import "CoolNavi.h"
11 | @interface CoolNaviViewController ()
12 |
13 | @property (nonatomic, strong) UITableView *tableView;
14 |
15 | @end
16 |
17 | @implementation CoolNaviViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | [self.navigationController setNavigationBarHidden:YES];
22 | [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
23 |
24 | self.tableView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
25 | CoolNavi *headerView = [[CoolNavi alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, kWindowHeight)backGroudImage:@"background" headerImageURL:@"http://d.hiphotos.baidu.com/image/pic/item/0ff41bd5ad6eddc4f263b0fc3adbb6fd52663334.jpg" title:@"妹子!" subTitle:@"个性签名, 啦啦啦!"];
26 | headerView.scrollView = self.tableView;
27 | headerView.imgActionBlock = ^(){
28 | NSLog(@"headerImageAction");
29 | };
30 | [self.view addSubview:headerView];
31 | // Do any additional setup after loading the view.
32 | }
33 |
34 | - (void)didReceiveMemoryWarning {
35 | [super didReceiveMemoryWarning];
36 | // Dispose of any resources that can be recreated.
37 | }
38 |
39 | - (UITableView *)tableView
40 | {
41 | if (!_tableView) {
42 | _tableView = [[UITableView alloc] init];
43 | _tableView.backgroundColor = [UIColor clearColor];
44 | _tableView.delegate = self;
45 | _tableView.dataSource = self;
46 | [self.view addSubview:_tableView];
47 | }
48 | return _tableView;
49 | }
50 |
51 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
52 | return 1;
53 | }
54 |
55 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
56 |
57 | return 40;
58 | }
59 |
60 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
61 | static NSString *cellReuseIdentifier = @"cell";
62 |
63 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellReuseIdentifier];
64 | if (!cell) {
65 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseIdentifier];
66 | cell.selectionStyle = UITableViewCellSelectionStyleNone;
67 | }
68 | cell.textLabel.text = [NSString stringWithFormat:@"test %ld",(long)indexPath.row];
69 | return cell;
70 | }
71 |
72 |
73 | #pragma mark - UITableViewDelegate
74 |
75 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
76 | return 44;
77 | }
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/CoolNaviDemo/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianisme/CoolNavi/0ee77be82a53e087854f7011596831dfbfc50fb1/CoolNaviDemo/Default-568h@2x.png
--------------------------------------------------------------------------------
/CoolNaviDemo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | }
43 | ],
44 | "info" : {
45 | "version" : 1,
46 | "author" : "xcode"
47 | }
48 | }
--------------------------------------------------------------------------------
/CoolNaviDemo/Images.xcassets/background.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "background@2x.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x",
15 | "filename" : "background@3x.png"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/CoolNaviDemo/Images.xcassets/background.imageset/background@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianisme/CoolNavi/0ee77be82a53e087854f7011596831dfbfc50fb1/CoolNaviDemo/Images.xcassets/background.imageset/background@2x.png
--------------------------------------------------------------------------------
/CoolNaviDemo/Images.xcassets/background.imageset/background@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianisme/CoolNavi/0ee77be82a53e087854f7011596831dfbfc50fb1/CoolNaviDemo/Images.xcassets/background.imageset/background@3x.png
--------------------------------------------------------------------------------
/CoolNaviDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.ianisme.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | NSAppTransportSecurity
38 |
39 | NSAllowsArbitraryLoads
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/CoolNaviDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/CoolNaviDemo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CoolNavi
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "CoolNavi.h"
11 |
12 | static CGFloat const kWindowHeight = 205.0f;
13 | static NSUInteger const kCellNum = 40;
14 | static NSUInteger const kRowHeight = 44;
15 | static NSString * const kCellIdentify = @"cell";
16 |
17 | @interface ViewController ()
18 |
19 | @property (nonatomic, strong) UITableView *tableView;
20 |
21 | @end
22 |
23 | @implementation ViewController
24 |
25 | #pragma mark - life sytle
26 |
27 | - (void)viewDidLoad {
28 | [super viewDidLoad];
29 |
30 | [self.navigationController setNavigationBarHidden:YES];
31 | [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
32 |
33 | self.tableView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));
34 | CoolNavi *headerView = [[CoolNavi alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), kWindowHeight)backGroudImage:@"background" headerImageURL:@"http://d.hiphotos.baidu.com/image/pic/item/0ff41bd5ad6eddc4f263b0fc3adbb6fd52663334.jpg" title:@"妹子!" subTitle:@"个性签名, 啦啦啦!"];
35 | headerView.scrollView = self.tableView;
36 | headerView.imgActionBlock = ^(){
37 | NSLog(@"headerImageAction");
38 | };
39 | [self.view addSubview:headerView];
40 | }
41 |
42 | - (void)didReceiveMemoryWarning {
43 | [super didReceiveMemoryWarning];
44 | // Dispose of any resources that can be recreated.
45 | }
46 |
47 | #pragma mark - getter and setter
48 |
49 | - (UITableView *)tableView
50 | {
51 | if (!_tableView) {
52 | _tableView = [[UITableView alloc] init];
53 | _tableView.backgroundColor = [UIColor clearColor];
54 | _tableView.delegate = self;
55 | _tableView.dataSource = self;
56 | [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kCellIdentify];
57 | [self.view addSubview:_tableView];
58 | }
59 | return _tableView;
60 | }
61 |
62 | #pragma mark - tableView Delegate and dataSource
63 |
64 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
65 |
66 | return kCellNum;
67 | }
68 |
69 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
70 |
71 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentify forIndexPath:indexPath];
72 | cell.textLabel.text = [NSString stringWithFormat:@"test %ld",(long)indexPath.row];
73 | return cell;
74 |
75 | }
76 |
77 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
78 | return kRowHeight;
79 | }
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/CoolNaviDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CoolNaviDemo
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/CoolNaviDemoTests/CoolNaviDemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoolNaviDemoTests.m
3 | // CoolNaviDemoTests
4 | //
5 | // Created by ian on 15/1/19.
6 | // Copyright (c) 2015年 ian. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface CoolNaviDemoTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation CoolNaviDemoTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CoolNaviDemoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.ianisme.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | NSAppTransportSecurity
24 |
25 | NSAllowsArbitraryLoads
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianisme/CoolNavi/0ee77be82a53e087854f7011596831dfbfc50fb1/Demo.gif
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2015 IAN
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '8.0'
2 | pod "SDWebImage"
3 |
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - SDWebImage (3.7.1):
3 | - SDWebImage/Core (= 3.7.1)
4 | - SDWebImage/Core (3.7.1)
5 |
6 | DEPENDENCIES:
7 | - SDWebImage
8 |
9 | SPEC CHECKSUMS:
10 | SDWebImage: 116e88633b5b416ea0ca4b334a4ac59cf72dd38d
11 |
12 | COCOAPODS: 0.35.0
13 |
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/NSData+ImageContentType.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/NSData+ImageContentType.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDImageCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDImageCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDWebImageCompat.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageCompat.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDWebImageDecoder.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageDecoder.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDWebImageDownloader.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloader.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDWebImageDownloaderOperation.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDWebImageManager.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDWebImageOperation.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/SDWebImagePrefetcher.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/UIButton+WebCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIButton+WebCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/UIImage+GIF.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImage+GIF.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/UIImage+MultiFormat.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/UIImageView+HighlightedWebCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/UIImageView+WebCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImageView+WebCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Build/SDWebImage/UIView+WebCacheOperation.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/NSData+ImageContentType.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/NSData+ImageContentType.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDImageCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDImageCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDWebImageCompat.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageCompat.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageDecoder.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDWebImageDownloader.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloader.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderOperation.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDWebImageManager.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDWebImageOperation.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImageOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/SDWebImagePrefetcher.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/UIButton+WebCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIButton+WebCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/UIImage+GIF.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImage+GIF.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/UIImage+MultiFormat.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/UIImageView+HighlightedWebCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/UIImageView+WebCache.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIImageView+WebCache.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/SDWebImage/UIView+WebCacheOperation.h:
--------------------------------------------------------------------------------
1 | ../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h
--------------------------------------------------------------------------------
/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - SDWebImage (3.7.1):
3 | - SDWebImage/Core (= 3.7.1)
4 | - SDWebImage/Core (3.7.1)
5 |
6 | DEPENDENCIES:
7 | - SDWebImage
8 |
9 | SPEC CHECKSUMS:
10 | SDWebImage: 116e88633b5b416ea0ca4b334a4ac59cf72dd38d
11 |
12 | COCOAPODS: 0.35.0
13 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/ian.xcuserdatad/xcschemes/Pods-SDWebImage.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
42 |
43 |
44 |
45 |
51 |
52 |
54 |
55 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/ian.xcuserdatad/xcschemes/Pods.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
42 |
43 |
44 |
45 |
51 |
52 |
54 |
55 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/ian.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Pods-SDWebImage.xcscheme
8 |
9 | isShown
10 |
11 |
12 | Pods.xcscheme
13 |
14 | isShown
15 |
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | C4C916BBEDA258A553104D1D
21 |
22 | primary
23 |
24 |
25 | D97323B381DC7E9F5A132392
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009 Olivier Poitrey
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is furnished
8 | to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
21 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/README.md:
--------------------------------------------------------------------------------
1 | Web Image
2 | =========
3 | [](https://travis-ci.org/rs/SDWebImage)
4 | [](http://cocoadocs.org/docsets/SDWebImage/)
5 | [](http://cocoadocs.org/docsets/SDWebImage/)
6 | [](https://www.apache.org/licenses/LICENSE-2.0.html)
7 |
8 | This library provides a category for UIImageView with support for remote images coming from the web.
9 |
10 | It provides:
11 |
12 | - An UIImageView category adding web image and cache management to the Cocoa Touch framework
13 | - An asynchronous image downloader
14 | - An asynchronous memory + disk image caching with automatic cache expiration handling
15 | - Animated GIF support
16 | - WebP format support
17 | - A background image decompression
18 | - A guarantee that the same URL won't be downloaded several times
19 | - A guarantee that bogus URLs won't be retried again and again
20 | - A guarantee that main thread will never be blocked
21 | - Performances!
22 | - Use GCD and ARC
23 | - Arm64 support
24 |
25 | NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.1.1
26 | minimum deployement version. If you need iOS < 5.0 support, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat).
27 |
28 | [How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F)
29 |
30 | Who Use It
31 | ----------
32 |
33 | Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list.
34 |
35 | How To Use
36 | ----------
37 |
38 | API documentation is available at [http://hackemist.com/SDWebImage/doc/](http://hackemist.com/SDWebImage/doc/)
39 |
40 | ### Using UIImageView+WebCache category with UITableView
41 |
42 | Just #import the UIImageView+WebCache.h header, and call the setImageWithURL:placeholderImage:
43 | method from the tableView:cellForRowAtIndexPath: UITableViewDataSource method. Everything will be
44 | handled for you, from async downloads to caching management.
45 |
46 | ```objective-c
47 | #import
48 |
49 | ...
50 |
51 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
52 | {
53 | static NSString *MyIdentifier = @"MyIdentifier";
54 |
55 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
56 |
57 | if (cell == nil)
58 | {
59 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
60 | reuseIdentifier:MyIdentifier] autorelease];
61 | }
62 |
63 | // Here we use the new provided setImageWithURL: method to load the web image
64 | [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
65 | placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
66 |
67 | cell.textLabel.text = @"My Text";
68 | return cell;
69 | }
70 | ```
71 |
72 | ### Using blocks
73 |
74 | With blocks, you can be notified about the image download progress and whenever the image retrival
75 | has completed with success or not:
76 |
77 | ```objective-c
78 | // Here we use the new provided setImageWithURL: method to load the web image
79 | [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
80 | placeholderImage:[UIImage imageNamed:@"placeholder.png"]
81 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {... completion code here ...}];
82 | ```
83 |
84 | Note: neither your success nor failure block will be call if your image request is canceled before completion.
85 |
86 | ### Using SDWebImageManager
87 |
88 | The SDWebImageManager is the class behind the UIImageView+WebCache category. It ties the
89 | asynchronous downloader with the image cache store. You can use this class directly to benefit
90 | from web image downloading with caching in another context than a UIView (ie: with Cocoa).
91 |
92 | Here is a simple example of how to use SDWebImageManager:
93 |
94 | ```objective-c
95 | SDWebImageManager *manager = [SDWebImageManager sharedManager];
96 | [manager downloadWithURL:imageURL
97 | options:0
98 | progress:^(NSInteger receivedSize, NSInteger expectedSize)
99 | {
100 | // progression tracking code
101 | }
102 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
103 | {
104 | if (image)
105 | {
106 | // do something with image
107 | }
108 | }];
109 | ```
110 |
111 | ### Using Asynchronous Image Downloader Independently
112 |
113 | It's also possible to use the async image downloader independently:
114 |
115 | ```objective-c
116 | [SDWebImageDownloader.sharedDownloader downloadImageWithURL:imageURL
117 | options:0
118 | progress:^(NSInteger receivedSize, NSInteger expectedSize)
119 | {
120 | // progression tracking code
121 | }
122 | completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished)
123 | {
124 | if (image && finished)
125 | {
126 | // do something with image
127 | }
128 | }];
129 | ```
130 |
131 | ### Using Asynchronous Image Caching Independently
132 |
133 | It is also possible to use the aync based image cache store independently. SDImageCache
134 | maintains a memory cache and an optional disk cache. Disk cache write operations are performed
135 | asynchronous so it doesn't add unnecessary latency to the UI.
136 |
137 | The SDImageCache class provides a singleton instance for convenience but you can create your own
138 | instance if you want to create separated cache namespace.
139 |
140 | To lookup the cache, you use the `queryDiskCacheForKey:done:` method. If the method returns nil, it means the cache
141 | doesn't currently own the image. You are thus responsible for generating and caching it. The cache
142 | key is an application unique identifier for the image to cache. It is generally the absolute URL of
143 | the image.
144 |
145 | ```objective-c
146 | SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"];
147 | [imageCache queryDiskCacheForKey:myCacheKey done:^(UIImage *image)
148 | {
149 | // image is not nil if image was found
150 | }];
151 | ```
152 |
153 | By default SDImageCache will lookup the disk cache if an image can't be found in the memory cache.
154 | You can prevent this from happening by calling the alternative method `imageFromMemoryCacheForKey:`.
155 |
156 | To store an image into the cache, you use the storeImage:forKey: method:
157 |
158 | ```objective-c
159 | [[SDImageCache sharedImageCache] storeImage:myImage forKey:myCacheKey];
160 | ```
161 |
162 | By default, the image will be stored in memory cache as well as on disk cache (asynchronously). If
163 | you want only the memory cache, use the alternative method storeImage:forKey:toDisk: with a negative
164 | third argument.
165 |
166 | ### Using cache key filter
167 |
168 | Sometime, you may not want to use the image URL as cache key because part of the URL is dynamic
169 | (i.e.: for access control purpose). SDWebImageManager provides a way to set a cache key filter that
170 | takes the NSURL as input, and output a cache key NSString.
171 |
172 | The following example sets a filter in the application delegate that will remove any query-string from
173 | the URL before to use it as a cache key:
174 |
175 | ```objective-c
176 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
177 | {
178 | SDWebImageManager.sharedManager.cacheKeyFilter:^(NSURL *url)
179 | {
180 | url = [[[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path] autorelease];
181 | return [url absoluteString];
182 | };
183 |
184 | // Your app init code...
185 | return YES;
186 | }
187 | ```
188 |
189 |
190 | Common Problems
191 | ---------------
192 |
193 | ### Using dynamic image size with UITableViewCell
194 |
195 | UITableView determins the size of the image by the first image set for a cell. If your remote images
196 | don't have the same size as your placeholder image, you may experience strange anamorphic scaling issue.
197 | The following article gives a way to workaround this issue:
198 |
199 | [http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/](http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/)
200 |
201 |
202 | ### Handle image refresh
203 |
204 | SDWebImage does very aggressive caching by default. It ignores all kind of caching control header returned by the HTTP server and cache the returned images with no time restriction. It implies your images URLs are static URLs pointing to images that never change. If the pointed image happen to change, some parts of the URL should change accordingly.
205 |
206 | If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the `SDWebImageRefreshCached` flag. This will slightly degrade the performance but will respect the HTTP caching control headers:
207 |
208 | ``` objective-c
209 | [imageView setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"]
210 | placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"]
211 | options:SDWebImageRefreshCached];
212 | ```
213 |
214 | ### Add a progress indicator
215 |
216 | See this category: https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage
217 |
218 | Installation
219 | ------------
220 |
221 | There are three ways to use SDWebImage in your project:
222 | - using Cocoapods
223 | - copying all the files into your project
224 | - importing the project as a static library
225 |
226 | ### Installation with CocoaPods
227 |
228 | [CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details.
229 |
230 | #### Podfile
231 | ```
232 | platform :ios, '6.1'
233 | pod 'SDWebImage', '~>3.6'
234 | ```
235 |
236 | ### Add the SDWebImage project to your project
237 |
238 | - Download and unzip the last version of the framework from the [download page](https://github.com/rs/SDWebImage/releases)
239 | - Right-click on the project navigator and select "Add Files to "Your Project":
240 | - In the dialog, select SDWebImage.framework:
241 | - Check the "Copy items into destination group's folder (if needed)" checkbox
242 |
243 | ### Add dependencies
244 |
245 | - In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block:
246 | - Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature:
247 |
248 | ### Add Linker Flag
249 |
250 | Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag:
251 |
252 | 
253 |
254 | Alternatively, if this causes compilation problems with frameworks that extend optional libraries, such as Parse, RestKit or opencv2, instead of the -ObjC flag use:
255 |
256 | ```
257 | -force_load SDWebImage.framework/Versions/Current/SDWebImage
258 | ```
259 |
260 | ### Import headers in your source files
261 |
262 | In the source files where you need to use the library, import the header file:
263 |
264 | ```objective-c
265 | #import
266 | ```
267 |
268 | ### Build Project
269 |
270 | At this point your workspace should build without error. If you are having problem, post to the Issue and the
271 | community can help you solve it.
272 |
273 | Future Enhancements
274 | -------------------
275 |
276 | - LRU memory cache cleanup instead of reset on memory warning
277 |
278 | ## Licenses
279 |
280 | All source code is licensed under the [MIT License](https://raw.github.com/rs/SDWebImage/master/LICENSE).
281 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Fabrice Aneche on 06/01/14.
3 | // Copyright (c) 2014 Dailymotion. All rights reserved.
4 | //
5 |
6 | #import
7 |
8 | @interface NSData (ImageContentType)
9 |
10 | /**
11 | * Compute the content type for an image data
12 | *
13 | * @param data the input data
14 | *
15 | * @return the content type as string (i.e. image/jpeg, image/gif)
16 | */
17 | + (NSString *)sd_contentTypeForImageData:(NSData *)data;
18 |
19 | @end
20 |
21 |
22 | @interface NSData (ImageContentTypeDeprecated)
23 |
24 | + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`");
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Fabrice Aneche on 06/01/14.
3 | // Copyright (c) 2014 Dailymotion. All rights reserved.
4 | //
5 |
6 | #import "NSData+ImageContentType.h"
7 |
8 |
9 | @implementation NSData (ImageContentType)
10 |
11 | + (NSString *)sd_contentTypeForImageData:(NSData *)data {
12 | uint8_t c;
13 | [data getBytes:&c length:1];
14 | switch (c) {
15 | case 0xFF:
16 | return @"image/jpeg";
17 | case 0x89:
18 | return @"image/png";
19 | case 0x47:
20 | return @"image/gif";
21 | case 0x49:
22 | case 0x4D:
23 | return @"image/tiff";
24 | case 0x52:
25 | // R as RIFF for WEBP
26 | if ([data length] < 12) {
27 | return nil;
28 | }
29 |
30 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding];
31 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) {
32 | return @"image/webp";
33 | }
34 |
35 | return nil;
36 | }
37 | return nil;
38 | }
39 |
40 | @end
41 |
42 |
43 | @implementation NSData (ImageContentTypeDeprecated)
44 |
45 | + (NSString *)contentTypeForImageData:(NSData *)data {
46 | return [self sd_contentTypeForImageData:data];
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDImageCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageCompat.h"
11 |
12 | typedef NS_ENUM(NSInteger, SDImageCacheType) {
13 | /**
14 | * The image wasn't available the SDWebImage caches, but was downloaded from the web.
15 | */
16 | SDImageCacheTypeNone,
17 | /**
18 | * The image was obtained from the disk cache.
19 | */
20 | SDImageCacheTypeDisk,
21 | /**
22 | * The image was obtained from the memory cache.
23 | */
24 | SDImageCacheTypeMemory
25 | };
26 |
27 | typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType);
28 |
29 | typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache);
30 |
31 | typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize);
32 |
33 | /**
34 | * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed
35 | * asynchronous so it doesn’t add unnecessary latency to the UI.
36 | */
37 | @interface SDImageCache : NSObject
38 |
39 | /**
40 | * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory.
41 | */
42 | @property (assign, nonatomic) NSUInteger maxMemoryCost;
43 |
44 | /**
45 | * The maximum length of time to keep an image in the cache, in seconds
46 | */
47 | @property (assign, nonatomic) NSInteger maxCacheAge;
48 |
49 | /**
50 | * The maximum size of the cache, in bytes.
51 | */
52 | @property (assign, nonatomic) NSUInteger maxCacheSize;
53 |
54 | /**
55 | * Returns global shared cache instance
56 | *
57 | * @return SDImageCache global instance
58 | */
59 | + (SDImageCache *)sharedImageCache;
60 |
61 | /**
62 | * Init a new cache store with a specific namespace
63 | *
64 | * @param ns The namespace to use for this cache store
65 | */
66 | - (id)initWithNamespace:(NSString *)ns;
67 |
68 | /**
69 | * Add a read-only cache path to search for images pre-cached by SDImageCache
70 | * Useful if you want to bundle pre-loaded images with your app
71 | *
72 | * @param path The path to use for this read-only cache path
73 | */
74 | - (void)addReadOnlyCachePath:(NSString *)path;
75 |
76 | /**
77 | * Store an image into memory and disk cache at the given key.
78 | *
79 | * @param image The image to store
80 | * @param key The unique image cache key, usually it's image absolute URL
81 | */
82 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key;
83 |
84 | /**
85 | * Store an image into memory and optionally disk cache at the given key.
86 | *
87 | * @param image The image to store
88 | * @param key The unique image cache key, usually it's image absolute URL
89 | * @param toDisk Store the image to disk cache if YES
90 | */
91 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk;
92 |
93 | /**
94 | * Store an image into memory and optionally disk cache at the given key.
95 | *
96 | * @param image The image to store
97 | * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage
98 | * @param imageData The image data as returned by the server, this representation will be used for disk storage
99 | * instead of converting the given image object into a storable/compressed image format in order
100 | * to save quality and CPU
101 | * @param key The unique image cache key, usually it's image absolute URL
102 | * @param toDisk Store the image to disk cache if YES
103 | */
104 | - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk;
105 |
106 | /**
107 | * Query the disk cache asynchronously.
108 | *
109 | * @param key The unique key used to store the wanted image
110 | */
111 | - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock;
112 |
113 | /**
114 | * Query the memory cache synchronously.
115 | *
116 | * @param key The unique key used to store the wanted image
117 | */
118 | - (UIImage *)imageFromMemoryCacheForKey:(NSString *)key;
119 |
120 | /**
121 | * Query the disk cache synchronously after checking the memory cache.
122 | *
123 | * @param key The unique key used to store the wanted image
124 | */
125 | - (UIImage *)imageFromDiskCacheForKey:(NSString *)key;
126 |
127 | /**
128 | * Remove the image from memory and disk cache synchronously
129 | *
130 | * @param key The unique image cache key
131 | */
132 | - (void)removeImageForKey:(NSString *)key;
133 |
134 |
135 | /**
136 | * Remove the image from memory and disk cache synchronously
137 | *
138 | * @param key The unique image cache key
139 | * @param completionBlock An block that should be executed after the image has been removed (optional)
140 | */
141 | - (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion;
142 |
143 | /**
144 | * Remove the image from memory and optionally disk cache synchronously
145 | *
146 | * @param key The unique image cache key
147 | * @param fromDisk Also remove cache entry from disk if YES
148 | */
149 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk;
150 |
151 | /**
152 | * Remove the image from memory and optionally disk cache synchronously
153 | *
154 | * @param key The unique image cache key
155 | * @param fromDisk Also remove cache entry from disk if YES
156 | * @param completionBlock An block that should be executed after the image has been removed (optional)
157 | */
158 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion;
159 |
160 | /**
161 | * Clear all memory cached images
162 | */
163 | - (void)clearMemory;
164 |
165 | /**
166 | * Clear all disk cached images. Non-blocking method - returns immediately.
167 | * @param completionBlock An block that should be executed after cache expiration completes (optional)
168 | */
169 | - (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion;
170 |
171 | /**
172 | * Clear all disk cached images
173 | * @see clearDiskOnCompletion:
174 | */
175 | - (void)clearDisk;
176 |
177 | /**
178 | * Remove all expired cached image from disk. Non-blocking method - returns immediately.
179 | * @param completionBlock An block that should be executed after cache expiration completes (optional)
180 | */
181 | - (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock;
182 |
183 | /**
184 | * Remove all expired cached image from disk
185 | * @see cleanDiskWithCompletionBlock:
186 | */
187 | - (void)cleanDisk;
188 |
189 | /**
190 | * Get the size used by the disk cache
191 | */
192 | - (NSUInteger)getSize;
193 |
194 | /**
195 | * Get the number of images in the disk cache
196 | */
197 | - (NSUInteger)getDiskCount;
198 |
199 | /**
200 | * Asynchronously calculate the disk cache's size.
201 | */
202 | - (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock;
203 |
204 | /**
205 | * Async check if image exists in disk cache already (does not load the image)
206 | *
207 | * @param key the key describing the url
208 | * @param completionBlock the block to be executed when the check is done.
209 | * @note the completion block will be always executed on the main queue
210 | */
211 | - (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock;
212 |
213 | /**
214 | * Check if image exists in disk cache already (does not load the image)
215 | *
216 | * @param key the key describing the url
217 | *
218 | * @return YES if an image exists for the given key
219 | */
220 | - (BOOL)diskImageExistsWithKey:(NSString *)key;
221 |
222 | /**
223 | * Get the cache path for a certain key (needs the cache path root folder)
224 | *
225 | * @param key the key (can be obtained from url using cacheKeyForURL)
226 | * @param path the cach path root folder
227 | *
228 | * @return the cache path
229 | */
230 | - (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path;
231 |
232 | /**
233 | * Get the default cache path for a certain key
234 | *
235 | * @param key the key (can be obtained from url using cacheKeyForURL)
236 | *
237 | * @return the default cache path
238 | */
239 | - (NSString *)defaultCachePathForKey:(NSString *)key;
240 |
241 | @end
242 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | * (c) Jamie Pinkham
5 | *
6 | * For the full copyright and license information, please view the LICENSE
7 | * file that was distributed with this source code.
8 | */
9 |
10 | #import
11 |
12 | #ifdef __OBJC_GC__
13 | #error SDWebImage does not support Objective-C Garbage Collection
14 | #endif
15 |
16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0
17 | #error SDWebImage doesn't support Deployement Target version < 5.0
18 | #endif
19 |
20 | #if !TARGET_OS_IPHONE
21 | #import
22 | #ifndef UIImage
23 | #define UIImage NSImage
24 | #endif
25 | #ifndef UIImageView
26 | #define UIImageView NSImageView
27 | #endif
28 | #else
29 |
30 | #import
31 |
32 | #endif
33 |
34 | #ifndef NS_ENUM
35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
36 | #endif
37 |
38 | #ifndef NS_OPTIONS
39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
40 | #endif
41 |
42 | #if OS_OBJECT_USE_OBJC
43 | #undef SDDispatchQueueRelease
44 | #undef SDDispatchQueueSetterSementics
45 | #define SDDispatchQueueRelease(q)
46 | #define SDDispatchQueueSetterSementics strong
47 | #else
48 | #undef SDDispatchQueueRelease
49 | #undef SDDispatchQueueSetterSementics
50 | #define SDDispatchQueueRelease(q) (dispatch_release(q))
51 | #define SDDispatchQueueSetterSementics assign
52 | #endif
53 |
54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image);
55 |
56 | typedef void(^SDWebImageNoParamsBlock)();
57 |
58 | #define dispatch_main_sync_safe(block)\
59 | if ([NSThread isMainThread]) {\
60 | block();\
61 | } else {\
62 | dispatch_sync(dispatch_get_main_queue(), block);\
63 | }
64 |
65 | #define dispatch_main_async_safe(block)\
66 | if ([NSThread isMainThread]) {\
67 | block();\
68 | } else {\
69 | dispatch_async(dispatch_get_main_queue(), block);\
70 | }
71 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m:
--------------------------------------------------------------------------------
1 | //
2 | // SDWebImageCompat.m
3 | // SDWebImage
4 | //
5 | // Created by Olivier Poitrey on 11/12/12.
6 | // Copyright (c) 2012 Dailymotion. All rights reserved.
7 | //
8 |
9 | #import "SDWebImageCompat.h"
10 |
11 | #if !__has_feature(objc_arc)
12 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
13 | #endif
14 |
15 | inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) {
16 | if (!image) {
17 | return nil;
18 | }
19 |
20 | if ([image.images count] > 0) {
21 | NSMutableArray *scaledImages = [NSMutableArray array];
22 |
23 | for (UIImage *tempImage in image.images) {
24 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)];
25 | }
26 |
27 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration];
28 | }
29 | else {
30 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
31 | CGFloat scale = 1.0;
32 | if (key.length >= 8) {
33 | // Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext)
34 | NSRange range = [key rangeOfString:@"@2x." options:0 range:NSMakeRange(key.length - 8, 5)];
35 | if (range.location != NSNotFound) {
36 | scale = 2.0;
37 | }
38 | }
39 |
40 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
41 | image = scaledImage;
42 | }
43 | return image;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * Created by james on 9/28/11.
6 | *
7 | * For the full copyright and license information, please view the LICENSE
8 | * file that was distributed with this source code.
9 | */
10 |
11 | #import
12 | #import "SDWebImageCompat.h"
13 |
14 | @interface UIImage (ForceDecode)
15 |
16 | + (UIImage *)decodedImageWithImage:(UIImage *)image;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * Created by james on 9/28/11.
6 | *
7 | * For the full copyright and license information, please view the LICENSE
8 | * file that was distributed with this source code.
9 | */
10 |
11 | #import "SDWebImageDecoder.h"
12 |
13 | @implementation UIImage (ForceDecode)
14 |
15 | + (UIImage *)decodedImageWithImage:(UIImage *)image {
16 | if (image.images) {
17 | // Do not decode animated images
18 | return image;
19 | }
20 |
21 | CGImageRef imageRef = image.CGImage;
22 | CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef));
23 | CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize};
24 |
25 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
26 | CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
27 |
28 | int infoMask = (bitmapInfo & kCGBitmapAlphaInfoMask);
29 | BOOL anyNonAlpha = (infoMask == kCGImageAlphaNone ||
30 | infoMask == kCGImageAlphaNoneSkipFirst ||
31 | infoMask == kCGImageAlphaNoneSkipLast);
32 |
33 | // CGBitmapContextCreate doesn't support kCGImageAlphaNone with RGB.
34 | // https://developer.apple.com/library/mac/#qa/qa1037/_index.html
35 | if (infoMask == kCGImageAlphaNone && CGColorSpaceGetNumberOfComponents(colorSpace) > 1) {
36 | // Unset the old alpha info.
37 | bitmapInfo &= ~kCGBitmapAlphaInfoMask;
38 |
39 | // Set noneSkipFirst.
40 | bitmapInfo |= kCGImageAlphaNoneSkipFirst;
41 | }
42 | // Some PNGs tell us they have alpha but only 3 components. Odd.
43 | else if (!anyNonAlpha && CGColorSpaceGetNumberOfComponents(colorSpace) == 3) {
44 | // Unset the old alpha info.
45 | bitmapInfo &= ~kCGBitmapAlphaInfoMask;
46 | bitmapInfo |= kCGImageAlphaPremultipliedFirst;
47 | }
48 |
49 | // It calculates the bytes-per-row based on the bitsPerComponent and width arguments.
50 | CGContextRef context = CGBitmapContextCreate(NULL,
51 | imageSize.width,
52 | imageSize.height,
53 | CGImageGetBitsPerComponent(imageRef),
54 | 0,
55 | colorSpace,
56 | bitmapInfo);
57 | CGColorSpaceRelease(colorSpace);
58 |
59 | // If failed, return undecompressed image
60 | if (!context) return image;
61 |
62 | CGContextDrawImage(context, imageRect, imageRef);
63 | CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context);
64 |
65 | CGContextRelease(context);
66 |
67 | UIImage *decompressedImage = [UIImage imageWithCGImage:decompressedImageRef scale:image.scale orientation:image.imageOrientation];
68 | CGImageRelease(decompressedImageRef);
69 | return decompressedImage;
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageCompat.h"
11 | #import "SDWebImageOperation.h"
12 |
13 | typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) {
14 | SDWebImageDownloaderLowPriority = 1 << 0,
15 | SDWebImageDownloaderProgressiveDownload = 1 << 1,
16 |
17 | /**
18 | * By default, request prevent the of NSURLCache. With this flag, NSURLCache
19 | * is used with default policies.
20 | */
21 | SDWebImageDownloaderUseNSURLCache = 1 << 2,
22 |
23 | /**
24 | * Call completion block with nil image/imageData if the image was read from NSURLCache
25 | * (to be combined with `SDWebImageDownloaderUseNSURLCache`).
26 | */
27 |
28 | SDWebImageDownloaderIgnoreCachedResponse = 1 << 3,
29 | /**
30 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for
31 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled.
32 | */
33 |
34 | SDWebImageDownloaderContinueInBackground = 1 << 4,
35 |
36 | /**
37 | * Handles cookies stored in NSHTTPCookieStore by setting
38 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES;
39 | */
40 | SDWebImageDownloaderHandleCookies = 1 << 5,
41 |
42 | /**
43 | * Enable to allow untrusted SSL ceriticates.
44 | * Useful for testing purposes. Use with caution in production.
45 | */
46 | SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6,
47 |
48 | /**
49 | * Put the image in the high priority queue.
50 | */
51 | SDWebImageDownloaderHighPriority = 1 << 7,
52 |
53 |
54 | };
55 |
56 | typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) {
57 | /**
58 | * Default value. All download operations will execute in queue style (first-in-first-out).
59 | */
60 | SDWebImageDownloaderFIFOExecutionOrder,
61 |
62 | /**
63 | * All download operations will execute in stack style (last-in-first-out).
64 | */
65 | SDWebImageDownloaderLIFOExecutionOrder
66 | };
67 |
68 | extern NSString *const SDWebImageDownloadStartNotification;
69 | extern NSString *const SDWebImageDownloadStopNotification;
70 |
71 | typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
72 |
73 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished);
74 |
75 | typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers);
76 |
77 | /**
78 | * Asynchronous downloader dedicated and optimized for image loading.
79 | */
80 | @interface SDWebImageDownloader : NSObject
81 |
82 | @property (assign, nonatomic) NSInteger maxConcurrentDownloads;
83 |
84 | /**
85 | * Shows the current amount of downloads that still need to be downloaded
86 | */
87 |
88 | @property (readonly, nonatomic) NSUInteger currentDownloadCount;
89 |
90 |
91 | /**
92 | * The timeout value (in seconds) for the download operation. Default: 15.0.
93 | */
94 | @property (assign, nonatomic) NSTimeInterval downloadTimeout;
95 |
96 |
97 | /**
98 | * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`.
99 | */
100 | @property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder;
101 |
102 | /**
103 | * Singleton method, returns the shared instance
104 | *
105 | * @return global shared instance of downloader class
106 | */
107 | + (SDWebImageDownloader *)sharedDownloader;
108 |
109 | /**
110 | * Set username
111 | */
112 | @property (strong, nonatomic) NSString *username;
113 |
114 | /**
115 | * Set password
116 | */
117 | @property (strong, nonatomic) NSString *password;
118 |
119 | /**
120 | * Set filter to pick headers for downloading image HTTP request.
121 | *
122 | * This block will be invoked for each downloading image request, returned
123 | * NSDictionary will be used as headers in corresponding HTTP request.
124 | */
125 | @property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter;
126 |
127 | /**
128 | * Set a value for a HTTP header to be appended to each download HTTP request.
129 | *
130 | * @param value The value for the header field. Use `nil` value to remove the header.
131 | * @param field The name of the header field to set.
132 | */
133 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
134 |
135 | /**
136 | * Returns the value of the specified HTTP header field.
137 | *
138 | * @return The value associated with the header field field, or `nil` if there is no corresponding header field.
139 | */
140 | - (NSString *)valueForHTTPHeaderField:(NSString *)field;
141 |
142 | /**
143 | * Creates a SDWebImageDownloader async downloader instance with a given URL
144 | *
145 | * The delegate will be informed when the image is finish downloaded or an error has happen.
146 | *
147 | * @see SDWebImageDownloaderDelegate
148 | *
149 | * @param url The URL to the image to download
150 | * @param options The options to be used for this download
151 | * @param progressBlock A block called repeatedly while the image is downloading
152 | * @param completedBlock A block called once the download is completed.
153 | * If the download succeeded, the image parameter is set, in case of error,
154 | * error parameter is set with the error. The last parameter is always YES
155 | * if SDWebImageDownloaderProgressiveDownload isn't use. With the
156 | * SDWebImageDownloaderProgressiveDownload option, this block is called
157 | * repeatedly with the partial image object and the finished argument set to NO
158 | * before to be called a last time with the full image and finished argument
159 | * set to YES. In case of error, the finished argument is always YES.
160 | *
161 | * @return A cancellable SDWebImageOperation
162 | */
163 | - (id )downloadImageWithURL:(NSURL *)url
164 | options:(SDWebImageDownloaderOptions)options
165 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
166 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock;
167 |
168 | /**
169 | * Sets the download queue suspension state
170 | */
171 | - (void)setSuspended:(BOOL)suspended;
172 |
173 | @end
174 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageDownloader.h"
10 | #import "SDWebImageDownloaderOperation.h"
11 | #import
12 |
13 | NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification";
14 | NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification";
15 |
16 | static NSString *const kProgressCallbackKey = @"progress";
17 | static NSString *const kCompletedCallbackKey = @"completed";
18 |
19 | @interface SDWebImageDownloader ()
20 |
21 | @property (strong, nonatomic) NSOperationQueue *downloadQueue;
22 | @property (weak, nonatomic) NSOperation *lastAddedOperation;
23 | @property (strong, nonatomic) NSMutableDictionary *URLCallbacks;
24 | @property (strong, nonatomic) NSMutableDictionary *HTTPHeaders;
25 | // This queue is used to serialize the handling of the network responses of all the download operation in a single queue
26 | @property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue;
27 |
28 | @end
29 |
30 | @implementation SDWebImageDownloader
31 |
32 | + (void)initialize {
33 | // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator )
34 | // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
35 | if (NSClassFromString(@"SDNetworkActivityIndicator")) {
36 |
37 | #pragma clang diagnostic push
38 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
39 | id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")];
40 | #pragma clang diagnostic pop
41 |
42 | // Remove observer in case it was previously added.
43 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil];
44 | [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil];
45 |
46 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator
47 | selector:NSSelectorFromString(@"startActivity")
48 | name:SDWebImageDownloadStartNotification object:nil];
49 | [[NSNotificationCenter defaultCenter] addObserver:activityIndicator
50 | selector:NSSelectorFromString(@"stopActivity")
51 | name:SDWebImageDownloadStopNotification object:nil];
52 | }
53 | }
54 |
55 | + (SDWebImageDownloader *)sharedDownloader {
56 | static dispatch_once_t once;
57 | static id instance;
58 | dispatch_once(&once, ^{
59 | instance = [self new];
60 | });
61 | return instance;
62 | }
63 |
64 | - (id)init {
65 | if ((self = [super init])) {
66 | _executionOrder = SDWebImageDownloaderFIFOExecutionOrder;
67 | _downloadQueue = [NSOperationQueue new];
68 | _downloadQueue.maxConcurrentOperationCount = 2;
69 | _URLCallbacks = [NSMutableDictionary new];
70 | _HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/webp,image/*;q=0.8" forKey:@"Accept"];
71 | _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT);
72 | _downloadTimeout = 15.0;
73 | }
74 | return self;
75 | }
76 |
77 | - (void)dealloc {
78 | [self.downloadQueue cancelAllOperations];
79 | SDDispatchQueueRelease(_barrierQueue);
80 | }
81 |
82 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field {
83 | if (value) {
84 | self.HTTPHeaders[field] = value;
85 | }
86 | else {
87 | [self.HTTPHeaders removeObjectForKey:field];
88 | }
89 | }
90 |
91 | - (NSString *)valueForHTTPHeaderField:(NSString *)field {
92 | return self.HTTPHeaders[field];
93 | }
94 |
95 | - (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads {
96 | _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads;
97 | }
98 |
99 | - (NSUInteger)currentDownloadCount {
100 | return _downloadQueue.operationCount;
101 | }
102 |
103 | - (NSInteger)maxConcurrentDownloads {
104 | return _downloadQueue.maxConcurrentOperationCount;
105 | }
106 |
107 | - (id )downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock {
108 | __block SDWebImageDownloaderOperation *operation;
109 | __weak SDWebImageDownloader *wself = self;
110 |
111 | [self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{
112 | NSTimeInterval timeoutInterval = wself.downloadTimeout;
113 | if (timeoutInterval == 0.0) {
114 | timeoutInterval = 15.0;
115 | }
116 |
117 | // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
118 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval];
119 | request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies);
120 | request.HTTPShouldUsePipelining = YES;
121 | if (wself.headersFilter) {
122 | request.allHTTPHeaderFields = wself.headersFilter(url, [wself.HTTPHeaders copy]);
123 | }
124 | else {
125 | request.allHTTPHeaderFields = wself.HTTPHeaders;
126 | }
127 | operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request
128 | options:options
129 | progress:^(NSInteger receivedSize, NSInteger expectedSize) {
130 | SDWebImageDownloader *sself = wself;
131 | if (!sself) return;
132 | NSArray *callbacksForURL = [sself callbacksForURL:url];
133 | for (NSDictionary *callbacks in callbacksForURL) {
134 | SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
135 | if (callback) callback(receivedSize, expectedSize);
136 | }
137 | }
138 | completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
139 | SDWebImageDownloader *sself = wself;
140 | if (!sself) return;
141 | NSArray *callbacksForURL = [sself callbacksForURL:url];
142 | if (finished) {
143 | [sself removeCallbacksForURL:url];
144 | }
145 | for (NSDictionary *callbacks in callbacksForURL) {
146 | SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
147 | if (callback) callback(image, data, error, finished);
148 | }
149 | }
150 | cancelled:^{
151 | SDWebImageDownloader *sself = wself;
152 | if (!sself) return;
153 | [sself removeCallbacksForURL:url];
154 | }];
155 |
156 | if (wself.username && wself.password) {
157 | operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession];
158 | }
159 |
160 | if (options & SDWebImageDownloaderHighPriority) {
161 | operation.queuePriority = NSOperationQueuePriorityHigh;
162 | } else if (options & SDWebImageDownloaderLowPriority) {
163 | operation.queuePriority = NSOperationQueuePriorityLow;
164 | }
165 |
166 | [wself.downloadQueue addOperation:operation];
167 | if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) {
168 | // Emulate LIFO execution order by systematically adding new operations as last operation's dependency
169 | [wself.lastAddedOperation addDependency:operation];
170 | wself.lastAddedOperation = operation;
171 | }
172 | }];
173 |
174 | return operation;
175 | }
176 |
177 | - (void)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock andCompletedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock forURL:(NSURL *)url createCallback:(SDWebImageNoParamsBlock)createCallback {
178 | // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data.
179 | if (url == nil) {
180 | if (completedBlock != nil) {
181 | completedBlock(nil, nil, nil, NO);
182 | }
183 | return;
184 | }
185 |
186 | dispatch_barrier_sync(self.barrierQueue, ^{
187 | BOOL first = NO;
188 | if (!self.URLCallbacks[url]) {
189 | self.URLCallbacks[url] = [NSMutableArray new];
190 | first = YES;
191 | }
192 |
193 | // Handle single download of simultaneous download request for the same URL
194 | NSMutableArray *callbacksForURL = self.URLCallbacks[url];
195 | NSMutableDictionary *callbacks = [NSMutableDictionary new];
196 | if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy];
197 | if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy];
198 | [callbacksForURL addObject:callbacks];
199 | self.URLCallbacks[url] = callbacksForURL;
200 |
201 | if (first) {
202 | createCallback();
203 | }
204 | });
205 | }
206 |
207 | - (NSArray *)callbacksForURL:(NSURL *)url {
208 | __block NSArray *callbacksForURL;
209 | dispatch_sync(self.barrierQueue, ^{
210 | callbacksForURL = self.URLCallbacks[url];
211 | });
212 | return [callbacksForURL copy];
213 | }
214 |
215 | - (void)removeCallbacksForURL:(NSURL *)url {
216 | dispatch_barrier_async(self.barrierQueue, ^{
217 | [self.URLCallbacks removeObjectForKey:url];
218 | });
219 | }
220 |
221 | - (void)setSuspended:(BOOL)suspended {
222 | [self.downloadQueue setSuspended:suspended];
223 | }
224 |
225 | @end
226 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageDownloader.h"
11 | #import "SDWebImageOperation.h"
12 |
13 | @interface SDWebImageDownloaderOperation : NSOperation
14 |
15 | /**
16 | * The request used by the operation's connection.
17 | */
18 | @property (strong, nonatomic, readonly) NSURLRequest *request;
19 |
20 | /**
21 | * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default.
22 | *
23 | * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`.
24 | */
25 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage;
26 |
27 | /**
28 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`.
29 | *
30 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present.
31 | */
32 | @property (nonatomic, strong) NSURLCredential *credential;
33 |
34 | /**
35 | * The SDWebImageDownloaderOptions for the receiver.
36 | */
37 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options;
38 |
39 | /**
40 | * Initializes a `SDWebImageDownloaderOperation` object
41 | *
42 | * @see SDWebImageDownloaderOperation
43 | *
44 | * @param request the URL request
45 | * @param options downloader options
46 | * @param progressBlock the block executed when a new chunk of data arrives.
47 | * @note the progress block is executed on a background queue
48 | * @param completedBlock the block executed when the download is done.
49 | * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue
50 | * @param cancelBlock the block executed if the download (operation) is cancelled
51 | *
52 | * @return the initialized instance
53 | */
54 | - (id)initWithRequest:(NSURLRequest *)request
55 | options:(SDWebImageDownloaderOptions)options
56 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
57 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock
58 | cancelled:(SDWebImageNoParamsBlock)cancelBlock;
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageManager.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageCompat.h"
10 | #import "SDWebImageOperation.h"
11 | #import "SDWebImageDownloader.h"
12 | #import "SDImageCache.h"
13 |
14 | typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
15 | /**
16 | * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying.
17 | * This flag disable this blacklisting.
18 | */
19 | SDWebImageRetryFailed = 1 << 0,
20 |
21 | /**
22 | * By default, image downloads are started during UI interactions, this flags disable this feature,
23 | * leading to delayed download on UIScrollView deceleration for instance.
24 | */
25 | SDWebImageLowPriority = 1 << 1,
26 |
27 | /**
28 | * This flag disables on-disk caching
29 | */
30 | SDWebImageCacheMemoryOnly = 1 << 2,
31 |
32 | /**
33 | * This flag enables progressive download, the image is displayed progressively during download as a browser would do.
34 | * By default, the image is only displayed once completely downloaded.
35 | */
36 | SDWebImageProgressiveDownload = 1 << 3,
37 |
38 | /**
39 | * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed.
40 | * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation.
41 | * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics.
42 | * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image.
43 | *
44 | * Use this flag only if you can't make your URLs static with embeded cache busting parameter.
45 | */
46 | SDWebImageRefreshCached = 1 << 4,
47 |
48 | /**
49 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for
50 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled.
51 | */
52 | SDWebImageContinueInBackground = 1 << 5,
53 |
54 | /**
55 | * Handles cookies stored in NSHTTPCookieStore by setting
56 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES;
57 | */
58 | SDWebImageHandleCookies = 1 << 6,
59 |
60 | /**
61 | * Enable to allow untrusted SSL ceriticates.
62 | * Useful for testing purposes. Use with caution in production.
63 | */
64 | SDWebImageAllowInvalidSSLCertificates = 1 << 7,
65 |
66 | /**
67 | * By default, image are loaded in the order they were queued. This flag move them to
68 | * the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which
69 | * could take a while).
70 | */
71 | SDWebImageHighPriority = 1 << 8,
72 |
73 | /**
74 | * By default, placeholder images are loaded while the image is loading. This flag will delay the loading
75 | * of the placeholder image until after the image has finished loading.
76 | */
77 | SDWebImageDelayPlaceholder = 1 << 9
78 | };
79 |
80 | typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL);
81 |
82 | typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL);
83 |
84 | typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url);
85 |
86 |
87 | @class SDWebImageManager;
88 |
89 | @protocol SDWebImageManagerDelegate
90 |
91 | @optional
92 |
93 | /**
94 | * Controls which image should be downloaded when the image is not found in the cache.
95 | *
96 | * @param imageManager The current `SDWebImageManager`
97 | * @param imageURL The url of the image to be downloaded
98 | *
99 | * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied.
100 | */
101 | - (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL;
102 |
103 | /**
104 | * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory.
105 | * NOTE: This method is called from a global queue in order to not to block the main thread.
106 | *
107 | * @param imageManager The current `SDWebImageManager`
108 | * @param image The image to transform
109 | * @param imageURL The url of the image to transform
110 | *
111 | * @return The transformed image object.
112 | */
113 | - (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL;
114 |
115 | @end
116 |
117 | /**
118 | * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes.
119 | * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache).
120 | * You can use this class directly to benefit from web image downloading with caching in another context than
121 | * a UIView.
122 | *
123 | * Here is a simple example of how to use SDWebImageManager:
124 | *
125 | * @code
126 |
127 | SDWebImageManager *manager = [SDWebImageManager sharedManager];
128 | [manager downloadWithURL:imageURL
129 | options:0
130 | progress:nil
131 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
132 | if (image) {
133 | // do something with image
134 | }
135 | }];
136 |
137 | * @endcode
138 | */
139 | @interface SDWebImageManager : NSObject
140 |
141 | @property (weak, nonatomic) id delegate;
142 |
143 | @property (strong, nonatomic, readonly) SDImageCache *imageCache;
144 | @property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader;
145 |
146 | /**
147 | * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can
148 | * be used to remove dynamic part of an image URL.
149 | *
150 | * The following example sets a filter in the application delegate that will remove any query-string from the
151 | * URL before to use it as a cache key:
152 | *
153 | * @code
154 |
155 | [[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) {
156 | url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path];
157 | return [url absoluteString];
158 | }];
159 |
160 | * @endcode
161 | */
162 | @property (copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter;
163 |
164 | /**
165 | * Returns global SDWebImageManager instance.
166 | *
167 | * @return SDWebImageManager shared instance
168 | */
169 | + (SDWebImageManager *)sharedManager;
170 |
171 | /**
172 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise.
173 | *
174 | * @param url The URL to the image
175 | * @param options A mask to specify options to use for this request
176 | * @param progressBlock A block called while image is downloading
177 | * @param completedBlock A block called when operation has been completed.
178 | *
179 | * This parameter is required.
180 | *
181 | * This block has no return value and takes the requested UIImage as first parameter.
182 | * In case of error the image parameter is nil and the second parameter may contain an NSError.
183 | *
184 | * The third parameter is an `SDImageCacheType` enum indicating if the image was retrived from the local cache
185 | * or from the memory cache or from the network.
186 | *
187 | * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is
188 | * downloading. This block is thus called repetidly with a partial image. When image is fully downloaded, the
189 | * block is called a last time with the full image and the last parameter set to YES.
190 | *
191 | * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation
192 | */
193 | - (id )downloadImageWithURL:(NSURL *)url
194 | options:(SDWebImageOptions)options
195 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
196 | completed:(SDWebImageCompletionWithFinishedBlock)completedBlock;
197 |
198 | /**
199 | * Saves image to cache for given URL
200 | *
201 | * @param image The image to cache
202 | * @param url The URL to the image
203 | *
204 | */
205 |
206 | - (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url;
207 |
208 | /**
209 | * Cancel all current opreations
210 | */
211 | - (void)cancelAll;
212 |
213 | /**
214 | * Check one or more operations running
215 | */
216 | - (BOOL)isRunning;
217 |
218 | /**
219 | * Check if image has already been cached
220 | *
221 | * @param url image url
222 | *
223 | * @return if the image was already cached
224 | */
225 | - (BOOL)cachedImageExistsForURL:(NSURL *)url;
226 |
227 | /**
228 | * Check if image has already been cached on disk only
229 | *
230 | * @param url image url
231 | *
232 | * @return if the image was already cached (disk only)
233 | */
234 | - (BOOL)diskImageExistsForURL:(NSURL *)url;
235 |
236 | /**
237 | * Async check if image has already been cached
238 | *
239 | * @param url image url
240 | * @param completionBlock the block to be executed when the check is finished
241 | *
242 | * @note the completion block is always executed on the main queue
243 | */
244 | - (void)cachedImageExistsForURL:(NSURL *)url
245 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock;
246 |
247 | /**
248 | * Async check if image has already been cached on disk only
249 | *
250 | * @param url image url
251 | * @param completionBlock the block to be executed when the check is finished
252 | *
253 | * @note the completion block is always executed on the main queue
254 | */
255 | - (void)diskImageExistsForURL:(NSURL *)url
256 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock;
257 |
258 |
259 | /**
260 | *Return the cache key for a given URL
261 | */
262 | - (NSString *)cacheKeyForURL:(NSURL *)url;
263 |
264 | @end
265 |
266 |
267 | #pragma mark - Deprecated
268 |
269 | typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`");
270 | typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`");
271 |
272 |
273 | @interface SDWebImageManager (Deprecated)
274 |
275 | /**
276 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise.
277 | *
278 | * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:`
279 | */
280 | - (id )downloadWithURL:(NSURL *)url
281 | options:(SDWebImageOptions)options
282 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
283 | completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`");
284 |
285 | @end
286 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageManager.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageManager.h"
10 | #import
11 |
12 | @interface SDWebImageCombinedOperation : NSObject
13 |
14 | @property (assign, nonatomic, getter = isCancelled) BOOL cancelled;
15 | @property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock;
16 | @property (strong, nonatomic) NSOperation *cacheOperation;
17 |
18 | @end
19 |
20 | @interface SDWebImageManager ()
21 |
22 | @property (strong, nonatomic, readwrite) SDImageCache *imageCache;
23 | @property (strong, nonatomic, readwrite) SDWebImageDownloader *imageDownloader;
24 | @property (strong, nonatomic) NSMutableArray *failedURLs;
25 | @property (strong, nonatomic) NSMutableArray *runningOperations;
26 |
27 | @end
28 |
29 | @implementation SDWebImageManager
30 |
31 | + (id)sharedManager {
32 | static dispatch_once_t once;
33 | static id instance;
34 | dispatch_once(&once, ^{
35 | instance = [self new];
36 | });
37 | return instance;
38 | }
39 |
40 | - (id)init {
41 | if ((self = [super init])) {
42 | _imageCache = [self createCache];
43 | _imageDownloader = [SDWebImageDownloader sharedDownloader];
44 | _failedURLs = [NSMutableArray new];
45 | _runningOperations = [NSMutableArray new];
46 | }
47 | return self;
48 | }
49 |
50 | - (SDImageCache *)createCache {
51 | return [SDImageCache sharedImageCache];
52 | }
53 |
54 | - (NSString *)cacheKeyForURL:(NSURL *)url {
55 | if (self.cacheKeyFilter) {
56 | return self.cacheKeyFilter(url);
57 | }
58 | else {
59 | return [url absoluteString];
60 | }
61 | }
62 |
63 | - (BOOL)cachedImageExistsForURL:(NSURL *)url {
64 | NSString *key = [self cacheKeyForURL:url];
65 | if ([self.imageCache imageFromMemoryCacheForKey:key] != nil) return YES;
66 | return [self.imageCache diskImageExistsWithKey:key];
67 | }
68 |
69 | - (BOOL)diskImageExistsForURL:(NSURL *)url {
70 | NSString *key = [self cacheKeyForURL:url];
71 | return [self.imageCache diskImageExistsWithKey:key];
72 | }
73 |
74 | - (void)cachedImageExistsForURL:(NSURL *)url
75 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock {
76 | NSString *key = [self cacheKeyForURL:url];
77 |
78 | BOOL isInMemoryCache = ([self.imageCache imageFromMemoryCacheForKey:key] != nil);
79 |
80 | if (isInMemoryCache) {
81 | // making sure we call the completion block on the main queue
82 | dispatch_async(dispatch_get_main_queue(), ^{
83 | if (completionBlock) {
84 | completionBlock(YES);
85 | }
86 | });
87 | return;
88 | }
89 |
90 | [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) {
91 | // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch
92 | if (completionBlock) {
93 | completionBlock(isInDiskCache);
94 | }
95 | }];
96 | }
97 |
98 | - (void)diskImageExistsForURL:(NSURL *)url
99 | completion:(SDWebImageCheckCacheCompletionBlock)completionBlock {
100 | NSString *key = [self cacheKeyForURL:url];
101 |
102 | [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) {
103 | // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch
104 | if (completionBlock) {
105 | completionBlock(isInDiskCache);
106 | }
107 | }];
108 | }
109 |
110 | - (id )downloadImageWithURL:(NSURL *)url
111 | options:(SDWebImageOptions)options
112 | progress:(SDWebImageDownloaderProgressBlock)progressBlock
113 | completed:(SDWebImageCompletionWithFinishedBlock)completedBlock {
114 | // Invoking this method without a completedBlock is pointless
115 | NSParameterAssert(completedBlock);
116 |
117 | // Very common mistake is to send the URL using NSString object instead of NSURL. For some strange reason, XCode won't
118 | // throw any warning for this type mismatch. Here we failsafe this error by allowing URLs to be passed as NSString.
119 | if ([url isKindOfClass:NSString.class]) {
120 | url = [NSURL URLWithString:(NSString *)url];
121 | }
122 |
123 | // Prevents app crashing on argument type error like sending NSNull instead of NSURL
124 | if (![url isKindOfClass:NSURL.class]) {
125 | url = nil;
126 | }
127 |
128 | __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new];
129 | __weak SDWebImageCombinedOperation *weakOperation = operation;
130 |
131 | BOOL isFailedUrl = NO;
132 | @synchronized (self.failedURLs) {
133 | isFailedUrl = [self.failedURLs containsObject:url];
134 | }
135 |
136 | if (!url || (!(options & SDWebImageRetryFailed) && isFailedUrl)) {
137 | dispatch_main_sync_safe(^{
138 | NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil];
139 | completedBlock(nil, error, SDImageCacheTypeNone, YES, url);
140 | });
141 | return operation;
142 | }
143 |
144 | @synchronized (self.runningOperations) {
145 | [self.runningOperations addObject:operation];
146 | }
147 | NSString *key = [self cacheKeyForURL:url];
148 |
149 | operation.cacheOperation = [self.imageCache queryDiskCacheForKey:key done:^(UIImage *image, SDImageCacheType cacheType) {
150 | if (operation.isCancelled) {
151 | @synchronized (self.runningOperations) {
152 | [self.runningOperations removeObject:operation];
153 | }
154 |
155 | return;
156 | }
157 |
158 | if ((!image || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) {
159 | if (image && options & SDWebImageRefreshCached) {
160 | dispatch_main_sync_safe(^{
161 | // If image was found in the cache bug SDWebImageRefreshCached is provided, notify about the cached image
162 | // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server.
163 | completedBlock(image, nil, cacheType, YES, url);
164 | });
165 | }
166 |
167 | // download if no image or requested to refresh anyway, and download allowed by delegate
168 | SDWebImageDownloaderOptions downloaderOptions = 0;
169 | if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority;
170 | if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload;
171 | if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache;
172 | if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground;
173 | if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies;
174 | if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates;
175 | if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority;
176 | if (image && options & SDWebImageRefreshCached) {
177 | // force progressive off if image already cached but forced refreshing
178 | downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;
179 | // ignore image read from NSURLCache if image if cached but force refreshing
180 | downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
181 | }
182 | id subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished) {
183 | if (weakOperation.isCancelled) {
184 | // Do nothing if the operation was cancelled
185 | // See #699 for more details
186 | // if we would call the completedBlock, there could be a race condition between this block and another completedBlock for the same object, so if this one is called second, we will overwrite the new data
187 | }
188 | else if (error) {
189 | dispatch_main_sync_safe(^{
190 | if (!weakOperation.isCancelled) {
191 | completedBlock(nil, error, SDImageCacheTypeNone, finished, url);
192 | }
193 | });
194 |
195 | if (error.code != NSURLErrorNotConnectedToInternet && error.code != NSURLErrorCancelled && error.code != NSURLErrorTimedOut) {
196 | @synchronized (self.failedURLs) {
197 | [self.failedURLs addObject:url];
198 | }
199 | }
200 | }
201 | else {
202 | BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly);
203 |
204 | if (options & SDWebImageRefreshCached && image && !downloadedImage) {
205 | // Image refresh hit the NSURLCache cache, do not call the completion block
206 | }
207 | // NOTE: We don't call transformDownloadedImage delegate method on animated images as most transformation code would mangle it
208 | else if (downloadedImage && !downloadedImage.images && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)]) {
209 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
210 | UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url];
211 |
212 | if (transformedImage && finished) {
213 | BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage];
214 | [self.imageCache storeImage:transformedImage recalculateFromImage:imageWasTransformed imageData:data forKey:key toDisk:cacheOnDisk];
215 | }
216 |
217 | dispatch_main_sync_safe(^{
218 | if (!weakOperation.isCancelled) {
219 | completedBlock(transformedImage, nil, SDImageCacheTypeNone, finished, url);
220 | }
221 | });
222 | });
223 | }
224 | else {
225 | if (downloadedImage && finished) {
226 | [self.imageCache storeImage:downloadedImage recalculateFromImage:NO imageData:data forKey:key toDisk:cacheOnDisk];
227 | }
228 |
229 | dispatch_main_sync_safe(^{
230 | if (!weakOperation.isCancelled) {
231 | completedBlock(downloadedImage, nil, SDImageCacheTypeNone, finished, url);
232 | }
233 | });
234 | }
235 | }
236 |
237 | if (finished) {
238 | @synchronized (self.runningOperations) {
239 | [self.runningOperations removeObject:operation];
240 | }
241 | }
242 | }];
243 | operation.cancelBlock = ^{
244 | [subOperation cancel];
245 |
246 | @synchronized (self.runningOperations) {
247 | [self.runningOperations removeObject:weakOperation];
248 | }
249 | };
250 | }
251 | else if (image) {
252 | dispatch_main_sync_safe(^{
253 | if (!weakOperation.isCancelled) {
254 | completedBlock(image, nil, cacheType, YES, url);
255 | }
256 | });
257 | @synchronized (self.runningOperations) {
258 | [self.runningOperations removeObject:operation];
259 | }
260 | }
261 | else {
262 | // Image not in cache and download disallowed by delegate
263 | dispatch_main_sync_safe(^{
264 | if (!weakOperation.isCancelled) {
265 | completedBlock(nil, nil, SDImageCacheTypeNone, YES, url);
266 | }
267 | });
268 | @synchronized (self.runningOperations) {
269 | [self.runningOperations removeObject:operation];
270 | }
271 | }
272 | }];
273 |
274 | return operation;
275 | }
276 |
277 | - (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url {
278 | if (image && url) {
279 | NSString *key = [self cacheKeyForURL:url];
280 | [self.imageCache storeImage:image forKey:key toDisk:YES];
281 | }
282 | }
283 |
284 | - (void)cancelAll {
285 | @synchronized (self.runningOperations) {
286 | [self.runningOperations makeObjectsPerformSelector:@selector(cancel)];
287 | [self.runningOperations removeAllObjects];
288 | }
289 | }
290 |
291 | - (BOOL)isRunning {
292 | return self.runningOperations.count > 0;
293 | }
294 |
295 | @end
296 |
297 |
298 | @implementation SDWebImageCombinedOperation
299 |
300 | - (void)setCancelBlock:(SDWebImageNoParamsBlock)cancelBlock {
301 | // check if the operation is already cancelled, then we just call the cancelBlock
302 | if (self.isCancelled) {
303 | if (cancelBlock) {
304 | cancelBlock();
305 | }
306 | _cancelBlock = nil; // don't forget to nil the cancelBlock, otherwise we will get crashes
307 | } else {
308 | _cancelBlock = [cancelBlock copy];
309 | }
310 | }
311 |
312 | - (void)cancel {
313 | self.cancelled = YES;
314 | if (self.cacheOperation) {
315 | [self.cacheOperation cancel];
316 | self.cacheOperation = nil;
317 | }
318 | if (self.cancelBlock) {
319 | self.cancelBlock();
320 |
321 | // TODO: this is a temporary fix to #809.
322 | // Until we can figure the exact cause of the crash, going with the ivar instead of the setter
323 | // self.cancelBlock = nil;
324 | _cancelBlock = nil;
325 | }
326 | }
327 |
328 | @end
329 |
330 |
331 | @implementation SDWebImageManager (Deprecated)
332 |
333 | // deprecated method, uses the non deprecated method
334 | // adapter for the completion block
335 | - (id )downloadWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedWithFinishedBlock)completedBlock {
336 | return [self downloadImageWithURL:url
337 | options:options
338 | progress:progressBlock
339 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
340 | if (completedBlock) {
341 | completedBlock(image, error, cacheType, finished);
342 | }
343 | }];
344 | }
345 |
346 | @end
347 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 |
11 | @protocol SDWebImageOperation
12 |
13 | - (void)cancel;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageManager.h"
11 |
12 | @class SDWebImagePrefetcher;
13 |
14 | @protocol SDWebImagePrefetcherDelegate
15 |
16 | @optional
17 |
18 | /**
19 | * Called when an image was prefetched.
20 | *
21 | * @param imagePrefetcher The current image prefetcher
22 | * @param imageURL The image url that was prefetched
23 | * @param finishedCount The total number of images that were prefetched (successful or not)
24 | * @param totalCount The total number of images that were to be prefetched
25 | */
26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount;
27 |
28 | /**
29 | * Called when all images are prefetched.
30 | * @param imagePrefetcher The current image prefetcher
31 | * @param totalCount The total number of images that were prefetched (whether successful or not)
32 | * @param skippedCount The total number of images that were skipped
33 | */
34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount;
35 |
36 | @end
37 |
38 | typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls);
39 | typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls);
40 |
41 | /**
42 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority.
43 | */
44 | @interface SDWebImagePrefetcher : NSObject
45 |
46 | /**
47 | * The web image manager
48 | */
49 | @property (strong, nonatomic, readonly) SDWebImageManager *manager;
50 |
51 | /**
52 | * Maximum number of URLs to prefetch at the same time. Defaults to 3.
53 | */
54 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads;
55 |
56 | /**
57 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority.
58 | */
59 | @property (nonatomic, assign) SDWebImageOptions options;
60 |
61 | @property (weak, nonatomic) id delegate;
62 |
63 | /**
64 | * Return the global image prefetcher instance.
65 | */
66 | + (SDWebImagePrefetcher *)sharedImagePrefetcher;
67 |
68 | /**
69 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching,
70 | * currently one image is downloaded at a time,
71 | * and skips images for failed downloads and proceed to the next image in the list
72 | *
73 | * @param urls list of URLs to prefetch
74 | */
75 | - (void)prefetchURLs:(NSArray *)urls;
76 |
77 | /**
78 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching,
79 | * currently one image is downloaded at a time,
80 | * and skips images for failed downloads and proceed to the next image in the list
81 | *
82 | * @param urls list of URLs to prefetch
83 | * @param progressBlock block to be called when progress updates;
84 | * first parameter is the number of completed (successful or not) requests,
85 | * second parameter is the total number of images originally requested to be prefetched
86 | * @param completionBlock block to be called when prefetching is completed
87 | * first param is the number of completed (successful or not) requests,
88 | * second parameter is the number of skipped requests
89 | */
90 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock;
91 |
92 | /**
93 | * Remove and cancel queued list
94 | */
95 | - (void)cancelPrefetching;
96 |
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImagePrefetcher.h"
10 |
11 | #if !defined(DEBUG) && !defined (SD_VERBOSE)
12 | #define NSLog(...)
13 | #endif
14 |
15 | @interface SDWebImagePrefetcher ()
16 |
17 | @property (strong, nonatomic) SDWebImageManager *manager;
18 | @property (strong, nonatomic) NSArray *prefetchURLs;
19 | @property (assign, nonatomic) NSUInteger requestedCount;
20 | @property (assign, nonatomic) NSUInteger skippedCount;
21 | @property (assign, nonatomic) NSUInteger finishedCount;
22 | @property (assign, nonatomic) NSTimeInterval startedTime;
23 | @property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock;
24 | @property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock;
25 |
26 | @end
27 |
28 | @implementation SDWebImagePrefetcher
29 |
30 | + (SDWebImagePrefetcher *)sharedImagePrefetcher {
31 | static dispatch_once_t once;
32 | static id instance;
33 | dispatch_once(&once, ^{
34 | instance = [self new];
35 | });
36 | return instance;
37 | }
38 |
39 | - (id)init {
40 | if ((self = [super init])) {
41 | _manager = [SDWebImageManager new];
42 | _options = SDWebImageLowPriority;
43 | self.maxConcurrentDownloads = 3;
44 | }
45 | return self;
46 | }
47 |
48 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads {
49 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads;
50 | }
51 |
52 | - (NSUInteger)maxConcurrentDownloads {
53 | return self.manager.imageDownloader.maxConcurrentDownloads;
54 | }
55 |
56 | - (void)startPrefetchingAtIndex:(NSUInteger)index {
57 | if (index >= self.prefetchURLs.count) return;
58 | self.requestedCount++;
59 | [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
60 | if (!finished) return;
61 | self.finishedCount++;
62 |
63 | if (image) {
64 | if (self.progressBlock) {
65 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]);
66 | }
67 | NSLog(@"Prefetched %@ out of %@", @(self.finishedCount), @(self.prefetchURLs.count));
68 | }
69 | else {
70 | if (self.progressBlock) {
71 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]);
72 | }
73 | NSLog(@"Prefetched %@ out of %@ (Failed)", @(self.finishedCount), @(self.prefetchURLs.count));
74 |
75 | // Add last failed
76 | self.skippedCount++;
77 | }
78 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) {
79 | [self.delegate imagePrefetcher:self
80 | didPrefetchURL:self.prefetchURLs[index]
81 | finishedCount:self.finishedCount
82 | totalCount:self.prefetchURLs.count
83 | ];
84 | }
85 |
86 | if (self.prefetchURLs.count > self.requestedCount) {
87 | dispatch_async(dispatch_get_main_queue(), ^{
88 | [self startPrefetchingAtIndex:self.requestedCount];
89 | });
90 | }
91 | else if (self.finishedCount == self.requestedCount) {
92 | [self reportStatus];
93 | if (self.completionBlock) {
94 | self.completionBlock(self.finishedCount, self.skippedCount);
95 | self.completionBlock = nil;
96 | }
97 | }
98 | }];
99 | }
100 |
101 | - (void)reportStatus {
102 | NSUInteger total = [self.prefetchURLs count];
103 | NSLog(@"Finished prefetching (%@ successful, %@ skipped, timeElasped %.2f)", @(total - self.skippedCount), @(self.skippedCount), CFAbsoluteTimeGetCurrent() - self.startedTime);
104 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) {
105 | [self.delegate imagePrefetcher:self
106 | didFinishWithTotalCount:(total - self.skippedCount)
107 | skippedCount:self.skippedCount
108 | ];
109 | }
110 | }
111 |
112 | - (void)prefetchURLs:(NSArray *)urls {
113 | [self prefetchURLs:urls progress:nil completed:nil];
114 | }
115 |
116 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock {
117 | [self cancelPrefetching]; // Prevent duplicate prefetch request
118 | self.startedTime = CFAbsoluteTimeGetCurrent();
119 | self.prefetchURLs = urls;
120 | self.completionBlock = completionBlock;
121 | self.progressBlock = progressBlock;
122 |
123 | // Starts prefetching from the very first image on the list with the max allowed concurrency
124 | NSUInteger listCount = self.prefetchURLs.count;
125 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) {
126 | [self startPrefetchingAtIndex:i];
127 | }
128 | }
129 |
130 | - (void)cancelPrefetching {
131 | self.prefetchURLs = nil;
132 | self.skippedCount = 0;
133 | self.requestedCount = 0;
134 | self.finishedCount = 0;
135 | [self.manager cancelAll];
136 | }
137 |
138 | @end
139 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageCompat.h"
10 | #import "SDWebImageManager.h"
11 |
12 | /**
13 | * Integrates SDWebImage async downloading and caching of remote images with UIButtonView.
14 | */
15 | @interface UIButton (WebCache)
16 |
17 | /**
18 | * Get the current image URL.
19 | */
20 | - (NSURL *)sd_currentImageURL;
21 |
22 | /**
23 | * Get the image URL for a control state.
24 | *
25 | * @param state Which state you want to know the URL for. The values are described in UIControlState.
26 | */
27 | - (NSURL *)sd_imageURLForState:(UIControlState)state;
28 |
29 | /**
30 | * Set the imageView `image` with an `url`.
31 | *
32 | * The download is asynchronous and cached.
33 | *
34 | * @param url The url for the image.
35 | * @param state The state that uses the specified title. The values are described in UIControlState.
36 | */
37 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state;
38 |
39 | /**
40 | * Set the imageView `image` with an `url` and a placeholder.
41 | *
42 | * The download is asynchronous and cached.
43 | *
44 | * @param url The url for the image.
45 | * @param state The state that uses the specified title. The values are described in UIControlState.
46 | * @param placeholder The image to be set initially, until the image request finishes.
47 | * @see sd_setImageWithURL:placeholderImage:options:
48 | */
49 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder;
50 |
51 | /**
52 | * Set the imageView `image` with an `url`, placeholder and custom options.
53 | *
54 | * The download is asynchronous and cached.
55 | *
56 | * @param url The url for the image.
57 | * @param state The state that uses the specified title. The values are described in UIControlState.
58 | * @param placeholder The image to be set initially, until the image request finishes.
59 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
60 | */
61 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;
62 |
63 | /**
64 | * Set the imageView `image` with an `url`.
65 | *
66 | * The download is asynchronous and cached.
67 | *
68 | * @param url The url for the image.
69 | * @param state The state that uses the specified title. The values are described in UIControlState.
70 | * @param completedBlock A block called when operation has been completed. This block has no return value
71 | * and takes the requested UIImage as first parameter. In case of error the image parameter
72 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
73 | * indicating if the image was retrived from the local cache of from the network.
74 | * The forth parameter is the original image url.
75 | */
76 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock;
77 |
78 | /**
79 | * Set the imageView `image` with an `url`, placeholder.
80 | *
81 | * The download is asynchronous and cached.
82 | *
83 | * @param url The url for the image.
84 | * @param state The state that uses the specified title. The values are described in UIControlState.
85 | * @param placeholder The image to be set initially, until the image request finishes.
86 | * @param completedBlock A block called when operation has been completed. This block has no return value
87 | * and takes the requested UIImage as first parameter. In case of error the image parameter
88 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
89 | * indicating if the image was retrived from the local cache of from the network.
90 | * The forth parameter is the original image url.
91 | */
92 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock;
93 |
94 | /**
95 | * Set the imageView `image` with an `url`, placeholder and custom options.
96 | *
97 | * The download is asynchronous and cached.
98 | *
99 | * @param url The url for the image.
100 | * @param state The state that uses the specified title. The values are described in UIControlState.
101 | * @param placeholder The image to be set initially, until the image request finishes.
102 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
103 | * @param completedBlock A block called when operation has been completed. This block has no return value
104 | * and takes the requested UIImage as first parameter. In case of error the image parameter
105 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
106 | * indicating if the image was retrived from the local cache of from the network.
107 | * The forth parameter is the original image url.
108 | */
109 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
110 |
111 | /**
112 | * Set the backgroundImageView `image` with an `url`.
113 | *
114 | * The download is asynchronous and cached.
115 | *
116 | * @param url The url for the image.
117 | * @param state The state that uses the specified title. The values are described in UIControlState.
118 | */
119 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state;
120 |
121 | /**
122 | * Set the backgroundImageView `image` with an `url` and a placeholder.
123 | *
124 | * The download is asynchronous and cached.
125 | *
126 | * @param url The url for the image.
127 | * @param state The state that uses the specified title. The values are described in UIControlState.
128 | * @param placeholder The image to be set initially, until the image request finishes.
129 | * @see sd_setImageWithURL:placeholderImage:options:
130 | */
131 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder;
132 |
133 | /**
134 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options.
135 | *
136 | * The download is asynchronous and cached.
137 | *
138 | * @param url The url for the image.
139 | * @param state The state that uses the specified title. The values are described in UIControlState.
140 | * @param placeholder The image to be set initially, until the image request finishes.
141 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
142 | */
143 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;
144 |
145 | /**
146 | * Set the backgroundImageView `image` with an `url`.
147 | *
148 | * The download is asynchronous and cached.
149 | *
150 | * @param url The url for the image.
151 | * @param state The state that uses the specified title. The values are described in UIControlState.
152 | * @param completedBlock A block called when operation has been completed. This block has no return value
153 | * and takes the requested UIImage as first parameter. In case of error the image parameter
154 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
155 | * indicating if the image was retrived from the local cache of from the network.
156 | * The forth parameter is the original image url.
157 | */
158 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock;
159 |
160 | /**
161 | * Set the backgroundImageView `image` with an `url`, placeholder.
162 | *
163 | * The download is asynchronous and cached.
164 | *
165 | * @param url The url for the image.
166 | * @param state The state that uses the specified title. The values are described in UIControlState.
167 | * @param placeholder The image to be set initially, until the image request finishes.
168 | * @param completedBlock A block called when operation has been completed. This block has no return value
169 | * and takes the requested UIImage as first parameter. In case of error the image parameter
170 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
171 | * indicating if the image was retrived from the local cache of from the network.
172 | * The forth parameter is the original image url.
173 | */
174 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock;
175 |
176 | /**
177 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options.
178 | *
179 | * The download is asynchronous and cached.
180 | *
181 | * @param url The url for the image.
182 | * @param placeholder The image to be set initially, until the image request finishes.
183 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
184 | * @param completedBlock A block called when operation has been completed. This block has no return value
185 | * and takes the requested UIImage as first parameter. In case of error the image parameter
186 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
187 | * indicating if the image was retrived from the local cache of from the network.
188 | * The forth parameter is the original image url.
189 | */
190 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
191 |
192 | /**
193 | * Cancel the current image download
194 | */
195 | - (void)sd_cancelImageLoadForState:(UIControlState)state;
196 |
197 | /**
198 | * Cancel the current backgroundImage download
199 | */
200 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state;
201 |
202 | @end
203 |
204 |
205 | @interface UIButton (WebCacheDeprecated)
206 |
207 | - (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`");
208 | - (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`");
209 |
210 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`");
211 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`");
212 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`");
213 |
214 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:completed:`");
215 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:completed:`");
216 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:completed:`");
217 |
218 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:`");
219 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:`");
220 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:`");
221 |
222 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:completed:`");
223 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`");
224 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`");
225 |
226 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`");
227 | - (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`");
228 |
229 | @end
230 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIButton+WebCache.h"
10 | #import "objc/runtime.h"
11 | #import "UIView+WebCacheOperation.h"
12 |
13 | static char imageURLStorageKey;
14 |
15 | @implementation UIButton (WebCache)
16 |
17 | - (NSURL *)sd_currentImageURL {
18 | NSURL *url = self.imageURLStorage[@(self.state)];
19 |
20 | if (!url) {
21 | url = self.imageURLStorage[@(UIControlStateNormal)];
22 | }
23 |
24 | return url;
25 | }
26 |
27 | - (NSURL *)sd_imageURLForState:(UIControlState)state {
28 | return self.imageURLStorage[@(state)];
29 | }
30 |
31 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state {
32 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
33 | }
34 |
35 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
36 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
37 | }
38 |
39 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
40 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
41 | }
42 |
43 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock {
44 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock];
45 | }
46 |
47 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock {
48 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock];
49 | }
50 |
51 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
52 |
53 | [self setImage:placeholder forState:state];
54 | [self sd_cancelImageLoadForState:state];
55 |
56 | if (!url) {
57 | [self.imageURLStorage removeObjectForKey:@(state)];
58 |
59 | dispatch_main_async_safe(^{
60 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
61 | if (completedBlock) {
62 | completedBlock(nil, error, SDImageCacheTypeNone, url);
63 | }
64 | });
65 |
66 | return;
67 | }
68 |
69 | self.imageURLStorage[@(state)] = url;
70 |
71 | __weak UIButton *wself = self;
72 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
73 | if (!wself) return;
74 | dispatch_main_sync_safe(^{
75 | __strong UIButton *sself = wself;
76 | if (!sself) return;
77 | if (image) {
78 | [sself setImage:image forState:state];
79 | }
80 | if (completedBlock && finished) {
81 | completedBlock(image, error, cacheType, url);
82 | }
83 | });
84 | }];
85 | [self sd_setImageLoadOperation:operation forState:state];
86 | }
87 |
88 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state {
89 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
90 | }
91 |
92 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
93 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
94 | }
95 |
96 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
97 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
98 | }
99 |
100 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock {
101 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock];
102 | }
103 |
104 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock {
105 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock];
106 | }
107 |
108 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
109 | [self sd_cancelImageLoadForState:state];
110 |
111 | [self setBackgroundImage:placeholder forState:state];
112 |
113 | if (url) {
114 | __weak UIButton *wself = self;
115 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
116 | if (!wself) return;
117 | dispatch_main_sync_safe(^{
118 | __strong UIButton *sself = wself;
119 | if (!sself) return;
120 | if (image) {
121 | [sself setBackgroundImage:image forState:state];
122 | }
123 | if (completedBlock && finished) {
124 | completedBlock(image, error, cacheType, url);
125 | }
126 | });
127 | }];
128 | [self sd_setBackgroundImageLoadOperation:operation forState:state];
129 | } else {
130 | dispatch_main_async_safe(^{
131 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
132 | if (completedBlock) {
133 | completedBlock(nil, error, SDImageCacheTypeNone, url);
134 | }
135 | });
136 | }
137 | }
138 |
139 | - (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state {
140 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
141 | }
142 |
143 | - (void)sd_cancelImageLoadForState:(UIControlState)state {
144 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
145 | }
146 |
147 | - (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state {
148 | [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
149 | }
150 |
151 | - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state {
152 | [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
153 | }
154 |
155 | - (NSMutableDictionary *)imageURLStorage {
156 | NSMutableDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey);
157 | if (!storage)
158 | {
159 | storage = [NSMutableDictionary dictionary];
160 | objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
161 | }
162 |
163 | return storage;
164 | }
165 |
166 | @end
167 |
168 |
169 | @implementation UIButton (WebCacheDeprecated)
170 |
171 | - (NSURL *)currentImageURL {
172 | return [self sd_currentImageURL];
173 | }
174 |
175 | - (NSURL *)imageURLForState:(UIControlState)state {
176 | return [self sd_imageURLForState:state];
177 | }
178 |
179 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state {
180 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
181 | }
182 |
183 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
184 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
185 | }
186 |
187 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
188 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
189 | }
190 |
191 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock {
192 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
193 | if (completedBlock) {
194 | completedBlock(image, error, cacheType);
195 | }
196 | }];
197 | }
198 |
199 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock {
200 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
201 | if (completedBlock) {
202 | completedBlock(image, error, cacheType);
203 | }
204 | }];
205 | }
206 |
207 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
208 | [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
209 | if (completedBlock) {
210 | completedBlock(image, error, cacheType);
211 | }
212 | }];
213 | }
214 |
215 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state {
216 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
217 | }
218 |
219 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder {
220 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil];
221 | }
222 |
223 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
224 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil];
225 | }
226 |
227 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock {
228 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
229 | if (completedBlock) {
230 | completedBlock(image, error, cacheType);
231 | }
232 | }];
233 | }
234 |
235 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock {
236 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
237 | if (completedBlock) {
238 | completedBlock(image, error, cacheType);
239 | }
240 | }];
241 | }
242 |
243 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
244 | [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
245 | if (completedBlock) {
246 | completedBlock(image, error, cacheType);
247 | }
248 | }];
249 | }
250 |
251 | - (void)cancelCurrentImageLoad {
252 | // in a backwards compatible manner, cancel for current state
253 | [self sd_cancelImageLoadForState:self.state];
254 | }
255 |
256 | - (void)cancelBackgroundImageLoadForState:(UIControlState)state {
257 | [self sd_cancelBackgroundImageLoadForState:state];
258 | }
259 |
260 | @end
261 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImage+GIF.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+GIF.h
3 | // LBGIFImage
4 | //
5 | // Created by Laurin Brandner on 06.01.12.
6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (GIF)
12 |
13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name;
14 |
15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data;
16 |
17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImage+GIF.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+GIF.m
3 | // LBGIFImage
4 | //
5 | // Created by Laurin Brandner on 06.01.12.
6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import "UIImage+GIF.h"
10 | #import
11 |
12 | @implementation UIImage (GIF)
13 |
14 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data {
15 | if (!data) {
16 | return nil;
17 | }
18 |
19 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
20 |
21 | size_t count = CGImageSourceGetCount(source);
22 |
23 | UIImage *animatedImage;
24 |
25 | if (count <= 1) {
26 | animatedImage = [[UIImage alloc] initWithData:data];
27 | }
28 | else {
29 | NSMutableArray *images = [NSMutableArray array];
30 |
31 | NSTimeInterval duration = 0.0f;
32 |
33 | for (size_t i = 0; i < count; i++) {
34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL);
35 |
36 | duration += [self sd_frameDurationAtIndex:i source:source];
37 |
38 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]];
39 |
40 | CGImageRelease(image);
41 | }
42 |
43 | if (!duration) {
44 | duration = (1.0f / 10.0f) * count;
45 | }
46 |
47 | animatedImage = [UIImage animatedImageWithImages:images duration:duration];
48 | }
49 |
50 | CFRelease(source);
51 |
52 | return animatedImage;
53 | }
54 |
55 | + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
56 | float frameDuration = 0.1f;
57 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
58 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
59 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary];
60 |
61 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime];
62 | if (delayTimeUnclampedProp) {
63 | frameDuration = [delayTimeUnclampedProp floatValue];
64 | }
65 | else {
66 |
67 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime];
68 | if (delayTimeProp) {
69 | frameDuration = [delayTimeProp floatValue];
70 | }
71 | }
72 |
73 | // Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
74 | // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
75 | // a duration of <= 10 ms. See and
76 | // for more information.
77 |
78 | if (frameDuration < 0.011f) {
79 | frameDuration = 0.100f;
80 | }
81 |
82 | CFRelease(cfFrameProperties);
83 | return frameDuration;
84 | }
85 |
86 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name {
87 | CGFloat scale = [UIScreen mainScreen].scale;
88 |
89 | if (scale > 1.0f) {
90 | NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"];
91 |
92 | NSData *data = [NSData dataWithContentsOfFile:retinaPath];
93 |
94 | if (data) {
95 | return [UIImage sd_animatedGIFWithData:data];
96 | }
97 |
98 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
99 |
100 | data = [NSData dataWithContentsOfFile:path];
101 |
102 | if (data) {
103 | return [UIImage sd_animatedGIFWithData:data];
104 | }
105 |
106 | return [UIImage imageNamed:name];
107 | }
108 | else {
109 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"];
110 |
111 | NSData *data = [NSData dataWithContentsOfFile:path];
112 |
113 | if (data) {
114 | return [UIImage sd_animatedGIFWithData:data];
115 | }
116 |
117 | return [UIImage imageNamed:name];
118 | }
119 | }
120 |
121 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size {
122 | if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) {
123 | return self;
124 | }
125 |
126 | CGSize scaledSize = size;
127 | CGPoint thumbnailPoint = CGPointZero;
128 |
129 | CGFloat widthFactor = size.width / self.size.width;
130 | CGFloat heightFactor = size.height / self.size.height;
131 | CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor;
132 | scaledSize.width = self.size.width * scaleFactor;
133 | scaledSize.height = self.size.height * scaleFactor;
134 |
135 | if (widthFactor > heightFactor) {
136 | thumbnailPoint.y = (size.height - scaledSize.height) * 0.5;
137 | }
138 | else if (widthFactor < heightFactor) {
139 | thumbnailPoint.x = (size.width - scaledSize.width) * 0.5;
140 | }
141 |
142 | NSMutableArray *scaledImages = [NSMutableArray array];
143 |
144 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
145 |
146 | for (UIImage *image in self.images) {
147 | [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)];
148 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
149 |
150 | [scaledImages addObject:newImage];
151 | }
152 |
153 | UIGraphicsEndImageContext();
154 |
155 | return [UIImage animatedImageWithImages:scaledImages duration:self.duration];
156 | }
157 |
158 | @end
159 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+MultiFormat.h
3 | // SDWebImage
4 | //
5 | // Created by Olivier Poitrey on 07/06/13.
6 | // Copyright (c) 2013 Dailymotion. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIImage (MultiFormat)
12 |
13 | + (UIImage *)sd_imageWithData:(NSData *)data;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+MultiFormat.m
3 | // SDWebImage
4 | //
5 | // Created by Olivier Poitrey on 07/06/13.
6 | // Copyright (c) 2013 Dailymotion. All rights reserved.
7 | //
8 |
9 | #import "UIImage+MultiFormat.h"
10 | #import "UIImage+GIF.h"
11 | #import "NSData+ImageContentType.h"
12 | #import
13 |
14 | #ifdef SD_WEBP
15 | #import "UIImage+WebP.h"
16 | #endif
17 |
18 | @implementation UIImage (MultiFormat)
19 |
20 | + (UIImage *)sd_imageWithData:(NSData *)data {
21 | UIImage *image;
22 | NSString *imageContentType = [NSData sd_contentTypeForImageData:data];
23 | if ([imageContentType isEqualToString:@"image/gif"]) {
24 | image = [UIImage sd_animatedGIFWithData:data];
25 | }
26 | #ifdef SD_WEBP
27 | else if ([imageContentType isEqualToString:@"image/webp"])
28 | {
29 | image = [UIImage sd_imageWithWebPData:data];
30 | }
31 | #endif
32 | else {
33 | image = [[UIImage alloc] initWithData:data];
34 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data];
35 | if (orientation != UIImageOrientationUp) {
36 | image = [UIImage imageWithCGImage:image.CGImage
37 | scale:image.scale
38 | orientation:orientation];
39 | }
40 | }
41 |
42 |
43 | return image;
44 | }
45 |
46 |
47 | +(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData {
48 | UIImageOrientation result = UIImageOrientationUp;
49 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
50 | if (imageSource) {
51 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
52 | if (properties) {
53 | CFTypeRef val;
54 | int exifOrientation;
55 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);
56 | if (val) {
57 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation);
58 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation];
59 | } // else - if it's not set it remains at up
60 | CFRelease((CFTypeRef) properties);
61 | } else {
62 | //NSLog(@"NO PROPERTIES, FAIL");
63 | }
64 | CFRelease(imageSource);
65 | }
66 | return result;
67 | }
68 |
69 | #pragma mark EXIF orientation tag converter
70 | // Convert an EXIF image orientation to an iOS one.
71 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html
72 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation {
73 | UIImageOrientation orientation = UIImageOrientationUp;
74 | switch (exifOrientation) {
75 | case 1:
76 | orientation = UIImageOrientationUp;
77 | break;
78 |
79 | case 3:
80 | orientation = UIImageOrientationDown;
81 | break;
82 |
83 | case 8:
84 | orientation = UIImageOrientationLeft;
85 | break;
86 |
87 | case 6:
88 | orientation = UIImageOrientationRight;
89 | break;
90 |
91 | case 2:
92 | orientation = UIImageOrientationUpMirrored;
93 | break;
94 |
95 | case 4:
96 | orientation = UIImageOrientationDownMirrored;
97 | break;
98 |
99 | case 5:
100 | orientation = UIImageOrientationLeftMirrored;
101 | break;
102 |
103 | case 7:
104 | orientation = UIImageOrientationRightMirrored;
105 | break;
106 | default:
107 | break;
108 | }
109 | return orientation;
110 | }
111 |
112 |
113 |
114 | @end
115 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageCompat.h"
11 | #import "SDWebImageManager.h"
12 |
13 | /**
14 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state.
15 | */
16 | @interface UIImageView (HighlightedWebCache)
17 |
18 | /**
19 | * Set the imageView `highlightedImage` with an `url`.
20 | *
21 | * The download is asynchronous and cached.
22 | *
23 | * @param url The url for the image.
24 | */
25 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url;
26 |
27 | /**
28 | * Set the imageView `highlightedImage` with an `url` and custom options.
29 | *
30 | * The download is asynchronous and cached.
31 | *
32 | * @param url The url for the image.
33 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
34 | */
35 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options;
36 |
37 | /**
38 | * Set the imageView `highlightedImage` with an `url`.
39 | *
40 | * The download is asynchronous and cached.
41 | *
42 | * @param url The url for the image.
43 | * @param completedBlock A block called when operation has been completed. This block has no return value
44 | * and takes the requested UIImage as first parameter. In case of error the image parameter
45 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
46 | * indicating if the image was retrived from the local cache of from the network.
47 | * The forth parameter is the original image url.
48 | */
49 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock;
50 |
51 | /**
52 | * Set the imageView `highlightedImage` with an `url` and custom options.
53 | *
54 | * The download is asynchronous and cached.
55 | *
56 | * @param url The url for the image.
57 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
58 | * @param completedBlock A block called when operation has been completed. This block has no return value
59 | * and takes the requested UIImage as first parameter. In case of error the image parameter
60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
61 | * indicating if the image was retrived from the local cache of from the network.
62 | * The forth parameter is the original image url.
63 | */
64 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
65 |
66 | /**
67 | * Set the imageView `highlightedImage` with an `url` and custom options.
68 | *
69 | * The download is asynchronous and cached.
70 | *
71 | * @param url The url for the image.
72 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
73 | * @param progressBlock A block called while image is downloading
74 | * @param completedBlock A block called when operation has been completed. This block has no return value
75 | * and takes the requested UIImage as first parameter. In case of error the image parameter
76 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
77 | * indicating if the image was retrived from the local cache of from the network.
78 | * The forth parameter is the original image url.
79 | */
80 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
81 |
82 | /**
83 | * Cancel the current download
84 | */
85 | - (void)sd_cancelCurrentHighlightedImageLoad;
86 |
87 | @end
88 |
89 |
90 | @interface UIImageView (HighlightedWebCacheDeprecated)
91 |
92 | - (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`");
93 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`");
94 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`");
95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`");
96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`");
97 |
98 | - (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`");
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIImageView+HighlightedWebCache.h"
10 | #import "UIView+WebCacheOperation.h"
11 |
12 | #define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage"
13 |
14 | @implementation UIImageView (HighlightedWebCache)
15 |
16 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url {
17 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil];
18 | }
19 |
20 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options {
21 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil];
22 | }
23 |
24 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock {
25 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock];
26 | }
27 |
28 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
29 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock];
30 | }
31 |
32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
33 | [self sd_cancelCurrentHighlightedImageLoad];
34 |
35 | if (url) {
36 | __weak UIImageView *wself = self;
37 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
38 | if (!wself) return;
39 | dispatch_main_sync_safe (^
40 | {
41 | if (!wself) return;
42 | if (image) {
43 | wself.highlightedImage = image;
44 | [wself setNeedsLayout];
45 | }
46 | if (completedBlock && finished) {
47 | completedBlock(image, error, cacheType, url);
48 | }
49 | });
50 | }];
51 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey];
52 | } else {
53 | dispatch_main_async_safe(^{
54 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
55 | if (completedBlock) {
56 | completedBlock(nil, error, SDImageCacheTypeNone, url);
57 | }
58 | });
59 | }
60 | }
61 |
62 | - (void)sd_cancelCurrentHighlightedImageLoad {
63 | [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey];
64 | }
65 |
66 | @end
67 |
68 |
69 | @implementation UIImageView (HighlightedWebCacheDeprecated)
70 |
71 | - (void)setHighlightedImageWithURL:(NSURL *)url {
72 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil];
73 | }
74 |
75 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options {
76 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil];
77 | }
78 |
79 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock {
80 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
81 | if (completedBlock) {
82 | completedBlock(image, error, cacheType);
83 | }
84 | }];
85 | }
86 |
87 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
88 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
89 | if (completedBlock) {
90 | completedBlock(image, error, cacheType);
91 | }
92 | }];
93 | }
94 |
95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock {
96 | [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
97 | if (completedBlock) {
98 | completedBlock(image, error, cacheType);
99 | }
100 | }];
101 | }
102 |
103 | - (void)cancelCurrentHighlightedImageLoad {
104 | [self sd_cancelCurrentHighlightedImageLoad];
105 | }
106 |
107 | @end
108 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "SDWebImageCompat.h"
10 | #import "SDWebImageManager.h"
11 |
12 | /**
13 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView.
14 | *
15 | * Usage with a UITableViewCell sub-class:
16 | *
17 | * @code
18 |
19 | #import
20 |
21 | ...
22 |
23 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
24 | {
25 | static NSString *MyIdentifier = @"MyIdentifier";
26 |
27 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
28 |
29 | if (cell == nil) {
30 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]
31 | autorelease];
32 | }
33 |
34 | // Here we use the provided sd_setImageWithURL: method to load the web image
35 | // Ensure you use a placeholder image otherwise cells will be initialized with no image
36 | [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
37 | placeholderImage:[UIImage imageNamed:@"placeholder"]];
38 |
39 | cell.textLabel.text = @"My Text";
40 | return cell;
41 | }
42 |
43 | * @endcode
44 | */
45 | @interface UIImageView (WebCache)
46 |
47 | /**
48 | * Get the current image URL.
49 | *
50 | * Note that because of the limitations of categories this property can get out of sync
51 | * if you use sd_setImage: directly.
52 | */
53 | - (NSURL *)sd_imageURL;
54 |
55 | /**
56 | * Set the imageView `image` with an `url`.
57 | *
58 | * The download is asynchronous and cached.
59 | *
60 | * @param url The url for the image.
61 | */
62 | - (void)sd_setImageWithURL:(NSURL *)url;
63 |
64 | /**
65 | * Set the imageView `image` with an `url` and a placeholder.
66 | *
67 | * The download is asynchronous and cached.
68 | *
69 | * @param url The url for the image.
70 | * @param placeholder The image to be set initially, until the image request finishes.
71 | * @see sd_setImageWithURL:placeholderImage:options:
72 | */
73 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder;
74 |
75 | /**
76 | * Set the imageView `image` with an `url`, placeholder and custom options.
77 | *
78 | * The download is asynchronous and cached.
79 | *
80 | * @param url The url for the image.
81 | * @param placeholder The image to be set initially, until the image request finishes.
82 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
83 | */
84 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options;
85 |
86 | /**
87 | * Set the imageView `image` with an `url`.
88 | *
89 | * The download is asynchronous and cached.
90 | *
91 | * @param url The url for the image.
92 | * @param completedBlock A block called when operation has been completed. This block has no return value
93 | * and takes the requested UIImage as first parameter. In case of error the image parameter
94 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
95 | * indicating if the image was retrived from the local cache of from the network.
96 | * The forth parameter is the original image url.
97 | */
98 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock;
99 |
100 | /**
101 | * Set the imageView `image` with an `url`, placeholder.
102 | *
103 | * The download is asynchronous and cached.
104 | *
105 | * @param url The url for the image.
106 | * @param placeholder The image to be set initially, until the image request finishes.
107 | * @param completedBlock A block called when operation has been completed. This block has no return value
108 | * and takes the requested UIImage as first parameter. In case of error the image parameter
109 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
110 | * indicating if the image was retrived from the local cache of from the network.
111 | * The forth parameter is the original image url.
112 | */
113 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock;
114 |
115 | /**
116 | * Set the imageView `image` with an `url`, placeholder and custom options.
117 | *
118 | * The download is asynchronous and cached.
119 | *
120 | * @param url The url for the image.
121 | * @param placeholder The image to be set initially, until the image request finishes.
122 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
123 | * @param completedBlock A block called when operation has been completed. This block has no return value
124 | * and takes the requested UIImage as first parameter. In case of error the image parameter
125 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
126 | * indicating if the image was retrived from the local cache of from the network.
127 | * The forth parameter is the original image url.
128 | */
129 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;
130 |
131 | /**
132 | * Set the imageView `image` with an `url`, placeholder and custom options.
133 | *
134 | * The download is asynchronous and cached.
135 | *
136 | * @param url The url for the image.
137 | * @param placeholder The image to be set initially, until the image request finishes.
138 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
139 | * @param progressBlock A block called while image is downloading
140 | * @param completedBlock A block called when operation has been completed. This block has no return value
141 | * and takes the requested UIImage as first parameter. In case of error the image parameter
142 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
143 | * indicating if the image was retrived from the local cache of from the network.
144 | * The forth parameter is the original image url.
145 | */
146 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
147 |
148 | /**
149 | * Set the imageView `image` with an `url` and a optionaly placeholder image.
150 | *
151 | * The download is asynchronous and cached.
152 | *
153 | * @param url The url for the image.
154 | * @param placeholder The image to be set initially, until the image request finishes.
155 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
156 | * @param progressBlock A block called while image is downloading
157 | * @param completedBlock A block called when operation has been completed. This block has no return value
158 | * and takes the requested UIImage as first parameter. In case of error the image parameter
159 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
160 | * indicating if the image was retrived from the local cache of from the network.
161 | * The forth parameter is the original image url.
162 | */
163 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;
164 |
165 | /**
166 | * Download an array of images and starts them in an animation loop
167 | *
168 | * @param arrayOfURLs An array of NSURL
169 | */
170 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs;
171 |
172 | /**
173 | * Cancel the current download
174 | */
175 | - (void)sd_cancelCurrentImageLoad;
176 |
177 | - (void)sd_cancelCurrentAnimationImagesLoad;
178 |
179 | @end
180 |
181 |
182 | @interface UIImageView (WebCacheDeprecated)
183 |
184 | - (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`");
185 |
186 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`");
187 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`");
188 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`");
189 |
190 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`");
191 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`");
192 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`");
193 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`");
194 |
195 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`");
196 |
197 | - (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`");
198 |
199 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`");
200 |
201 | @end
202 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIImageView+WebCache.h"
10 | #import "objc/runtime.h"
11 | #import "UIView+WebCacheOperation.h"
12 |
13 | static char imageURLKey;
14 |
15 | @implementation UIImageView (WebCache)
16 |
17 | - (void)sd_setImageWithURL:(NSURL *)url {
18 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
19 | }
20 |
21 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder {
22 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
23 | }
24 |
25 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
26 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil];
27 | }
28 |
29 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock {
30 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock];
31 | }
32 |
33 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock {
34 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock];
35 | }
36 |
37 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
38 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
39 | }
40 |
41 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
42 | [self sd_cancelCurrentImageLoad];
43 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
44 |
45 | if (!(options & SDWebImageDelayPlaceholder)) {
46 | self.image = placeholder;
47 | }
48 |
49 | if (url) {
50 | __weak UIImageView *wself = self;
51 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
52 | if (!wself) return;
53 | dispatch_main_sync_safe(^{
54 | if (!wself) return;
55 | if (image) {
56 | wself.image = image;
57 | [wself setNeedsLayout];
58 | } else {
59 | if ((options & SDWebImageDelayPlaceholder)) {
60 | wself.image = placeholder;
61 | [wself setNeedsLayout];
62 | }
63 | }
64 | if (completedBlock && finished) {
65 | completedBlock(image, error, cacheType, url);
66 | }
67 | });
68 | }];
69 | [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"];
70 | } else {
71 | dispatch_main_async_safe(^{
72 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
73 | if (completedBlock) {
74 | completedBlock(nil, error, SDImageCacheTypeNone, url);
75 | }
76 | });
77 | }
78 | }
79 |
80 | - (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
81 | NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url];
82 | UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key];
83 |
84 | [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock];
85 | }
86 |
87 | - (NSURL *)sd_imageURL {
88 | return objc_getAssociatedObject(self, &imageURLKey);
89 | }
90 |
91 | - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
92 | [self sd_cancelCurrentAnimationImagesLoad];
93 | __weak UIImageView *wself = self;
94 |
95 | NSMutableArray *operationsArray = [[NSMutableArray alloc] init];
96 |
97 | for (NSURL *logoImageURL in arrayOfURLs) {
98 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
99 | if (!wself) return;
100 | dispatch_main_sync_safe(^{
101 | __strong UIImageView *sself = wself;
102 | [sself stopAnimating];
103 | if (sself && image) {
104 | NSMutableArray *currentImages = [[sself animationImages] mutableCopy];
105 | if (!currentImages) {
106 | currentImages = [[NSMutableArray alloc] init];
107 | }
108 | [currentImages addObject:image];
109 |
110 | sself.animationImages = currentImages;
111 | [sself setNeedsLayout];
112 | }
113 | [sself startAnimating];
114 | });
115 | }];
116 | [operationsArray addObject:operation];
117 | }
118 |
119 | [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"];
120 | }
121 |
122 | - (void)sd_cancelCurrentImageLoad {
123 | [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"];
124 | }
125 |
126 | - (void)sd_cancelCurrentAnimationImagesLoad {
127 | [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"];
128 | }
129 |
130 | @end
131 |
132 |
133 | @implementation UIImageView (WebCacheDeprecated)
134 |
135 | - (NSURL *)imageURL {
136 | return [self sd_imageURL];
137 | }
138 |
139 | - (void)setImageWithURL:(NSURL *)url {
140 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
141 | }
142 |
143 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder {
144 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
145 | }
146 |
147 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
148 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil];
149 | }
150 |
151 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock {
152 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
153 | if (completedBlock) {
154 | completedBlock(image, error, cacheType);
155 | }
156 | }];
157 | }
158 |
159 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock {
160 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
161 | if (completedBlock) {
162 | completedBlock(image, error, cacheType);
163 | }
164 | }];
165 | }
166 |
167 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
168 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
169 | if (completedBlock) {
170 | completedBlock(image, error, cacheType);
171 | }
172 | }];
173 | }
174 |
175 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock {
176 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
177 | if (completedBlock) {
178 | completedBlock(image, error, cacheType);
179 | }
180 | }];
181 | }
182 |
183 | - (void)cancelCurrentArrayLoad {
184 | [self sd_cancelCurrentAnimationImagesLoad];
185 | }
186 |
187 | - (void)cancelCurrentImageLoad {
188 | [self sd_cancelCurrentImageLoad];
189 | }
190 |
191 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
192 | [self sd_setAnimationImagesWithURLs:arrayOfURLs];
193 | }
194 |
195 | @end
196 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import
10 | #import "SDWebImageManager.h"
11 |
12 | @interface UIView (WebCacheOperation)
13 |
14 | /**
15 | * Set the image load operation (storage in a UIView based dictionary)
16 | *
17 | * @param operation the operation
18 | * @param key key for storing the operation
19 | */
20 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key;
21 |
22 | /**
23 | * Cancel all operations for the current UIView and key
24 | *
25 | * @param key key for identifying the operations
26 | */
27 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key;
28 |
29 | /**
30 | * Just remove the operations corresponding to the current UIView and key without cancelling them
31 | *
32 | * @param key key for identifying the operations
33 | */
34 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of the SDWebImage package.
3 | * (c) Olivier Poitrey
4 | *
5 | * For the full copyright and license information, please view the LICENSE
6 | * file that was distributed with this source code.
7 | */
8 |
9 | #import "UIView+WebCacheOperation.h"
10 | #import "objc/runtime.h"
11 |
12 | static char loadOperationKey;
13 |
14 | @implementation UIView (WebCacheOperation)
15 |
16 | - (NSMutableDictionary *)operationDictionary {
17 | NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey);
18 | if (operations) {
19 | return operations;
20 | }
21 | operations = [NSMutableDictionary dictionary];
22 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
23 | return operations;
24 | }
25 |
26 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key {
27 | [self sd_cancelImageLoadOperationWithKey:key];
28 | NSMutableDictionary *operationDictionary = [self operationDictionary];
29 | [operationDictionary setObject:operation forKey:key];
30 | }
31 |
32 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key {
33 | // Cancel in progress downloader from queue
34 | NSMutableDictionary *operationDictionary = [self operationDictionary];
35 | id operations = [operationDictionary objectForKey:key];
36 | if (operations) {
37 | if ([operations isKindOfClass:[NSArray class]]) {
38 | for (id operation in operations) {
39 | if (operation) {
40 | [operation cancel];
41 | }
42 | }
43 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){
44 | [(id) operations cancel];
45 | }
46 | [operationDictionary removeObjectForKey:key];
47 | }
48 | }
49 |
50 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key {
51 | NSMutableDictionary *operationDictionary = [self operationDictionary];
52 | [operationDictionary removeObjectForKey:key];
53 | }
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage-Private.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods-SDWebImage.xcconfig"
2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Build" "${PODS_ROOT}/Headers/Build/SDWebImage" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage"
4 | OTHER_LDFLAGS = ${PODS_SDWEBIMAGE_OTHER_LDFLAGS} -ObjC
5 | PODS_ROOT = ${SRCROOT}
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_SDWebImage : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_SDWebImage
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 | #import "Pods-environment.h"
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-SDWebImage/Pods-SDWebImage.xcconfig:
--------------------------------------------------------------------------------
1 | PODS_SDWEBIMAGE_OTHER_LDFLAGS = -framework "ImageIO"
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown:
--------------------------------------------------------------------------------
1 | # Acknowledgements
2 | This application makes use of the following third party libraries:
3 |
4 | ## SDWebImage
5 |
6 | Copyright (c) 2009 Olivier Poitrey
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy
9 | of this software and associated documentation files (the "Software"), to deal
10 | in the Software without restriction, including without limitation the rights
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the Software is furnished
13 | to do so, subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in all
16 | copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | THE SOFTWARE.
25 |
26 |
27 | Generated by CocoaPods - http://cocoapods.org
28 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-acknowledgements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | FooterText
9 | This application makes use of the following third party libraries:
10 | Title
11 | Acknowledgements
12 | Type
13 | PSGroupSpecifier
14 |
15 |
16 | FooterText
17 | Copyright (c) 2009 Olivier Poitrey <rs@dailymotion.com>
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is furnished
24 | to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in all
27 | copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.
36 |
37 |
38 | Title
39 | SDWebImage
40 | Type
41 | PSGroupSpecifier
42 |
43 |
44 | FooterText
45 | Generated by CocoaPods - http://cocoapods.org
46 | Title
47 |
48 | Type
49 | PSGroupSpecifier
50 |
51 |
52 | StringsTable
53 | Acknowledgements
54 | Title
55 | Acknowledgements
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods : NSObject
3 | @end
4 | @implementation PodsDummy_Pods
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-environment.h:
--------------------------------------------------------------------------------
1 |
2 | // To check if a library is compiled with CocoaPods you
3 | // can use the `COCOAPODS` macro definition which is
4 | // defined in the xcconfigs so it is available in
5 | // headers also when they are imported in the client
6 | // project.
7 |
8 |
9 | // SDWebImage
10 | #define COCOAPODS_POD_AVAILABLE_SDWebImage
11 | #define COCOAPODS_VERSION_MAJOR_SDWebImage 3
12 | #define COCOAPODS_VERSION_MINOR_SDWebImage 7
13 | #define COCOAPODS_VERSION_PATCH_SDWebImage 1
14 |
15 | // SDWebImage/Core
16 | #define COCOAPODS_POD_AVAILABLE_SDWebImage_Core
17 | #define COCOAPODS_VERSION_MAJOR_SDWebImage_Core 3
18 | #define COCOAPODS_VERSION_MINOR_SDWebImage_Core 7
19 | #define COCOAPODS_VERSION_PATCH_SDWebImage_Core 1
20 |
21 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-resources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
5 |
6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
7 | > "$RESOURCES_TO_COPY"
8 |
9 | install_resource()
10 | {
11 | case $1 in
12 | *.storyboard)
13 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
14 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
15 | ;;
16 | *.xib)
17 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
18 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
19 | ;;
20 | *.framework)
21 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
22 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
23 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
24 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
25 | ;;
26 | *.xcdatamodel)
27 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
28 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
29 | ;;
30 | *.xcdatamodeld)
31 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
32 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
33 | ;;
34 | *.xcmappingmodel)
35 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\""
36 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm"
37 | ;;
38 | *.xcassets)
39 | ;;
40 | /*)
41 | echo "$1"
42 | echo "$1" >> "$RESOURCES_TO_COPY"
43 | ;;
44 | *)
45 | echo "${PODS_ROOT}/$1"
46 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
47 | ;;
48 | esac
49 | }
50 |
51 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
52 | if [[ "${ACTION}" == "install" ]]; then
53 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
54 | fi
55 | rm -f "$RESOURCES_TO_COPY"
56 |
57 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ]
58 | then
59 | case "${TARGETED_DEVICE_FAMILY}" in
60 | 1,2)
61 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
62 | ;;
63 | 1)
64 | TARGET_DEVICE_ARGS="--target-device iphone"
65 | ;;
66 | 2)
67 | TARGET_DEVICE_ARGS="--target-device ipad"
68 | ;;
69 | *)
70 | TARGET_DEVICE_ARGS="--target-device mac"
71 | ;;
72 | esac
73 | find "${PWD}" -name "*.xcassets" -print0 | xargs -0 actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
74 | fi
75 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods.debug.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage"
3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage"
4 | OTHER_LDFLAGS = -ObjC -l"Pods-SDWebImage" -framework "ImageIO"
5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
6 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods.release.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage"
3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage"
4 | OTHER_LDFLAGS = -ObjC -l"Pods-SDWebImage" -framework "ImageIO"
5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
6 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CoolNavi [](https://github.com/ianisme/CoolNavi) [](https://github.com/ianisme/CoolNavi/fork)
2 |
3 | ### 说明:
4 | - 简单实现一个炫酷的个人中心界面
5 |
6 | ### 功能如下:
7 |
8 | - 1.上下移动头像可以缩小放大
9 | - 2.用户头像可以点击
10 |
11 | ### 效果演示:
12 | 
13 | ### Swift版:
14 | https://github.com/ianisme/CoolNaviDemo_Swift
15 |
--------------------------------------------------------------------------------