Skip to content

Instantly share code, notes, and snippets.

@linjunpop
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linjunpop/18e1db79e4364137e4b6 to your computer and use it in GitHub Desktop.
Save linjunpop/18e1db79e4364137e4b6 to your computer and use it in GitHub Desktop.
UIImage 加载七牛图片,Retina 支持
#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