Last active
August 29, 2015 14:19
-
-
Save linjunpop/18e1db79e4364137e4b6 to your computer and use it in GitHub Desktop.
UIImage 加载七牛图片,Retina 支持
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIImageView+Qiniu.h" | |
#import <UIImageView+AFNetworking.h> | |
@implementation UIImageView (Qiniu) | |
- (void)qiniu_setImageWithURL:(NSURL *)url { | |
NSURLComponents *components = [[NSURLComponents alloc] initWithURL:url resolvingAgainstBaseURL:NO]; | |
CGFloat scale = [[UIScreen mainScreen] scale]; | |
CGSize size = self.frame.size; | |
NSString *query = [NSString stringWithFormat:@"imageView2/2/w/%1.0f/h/%1.0f/format/JPG", size.width * scale, size.height * scale]; | |
[components setQuery:query]; | |
NSLog(@"Loading image: %@", [components URL]); | |
[self setImageWithURL:[components URL]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment