iOS 获取网络图片的尺寸

释放双眼,带上耳机,听听看~!

1. 使用系统方法直接获取

NSData *data = [NSData dataWithContentsOfURL:[NSURLURLWithString:@"http://s12.mogujie.cn/b7/bao/131011/1jix9_kqywmrcdkfbg26dwgfjeg5sckzsew_400x540.jpg_200x999.jpg"]];
UIImage *image = [UIImage imageWithData:data];
NSLog(@"w = %f,h = %f",image.size.width,image.size.height);

2. 使用SDWebImage 获取

UIImageView *view = [[UIImageView alloc] init];
self.viewaddSubview:view];
[view sd_setImageWithURL:[NSURLURLWithString:imageName placeholderImage:[UIImageimageNamed:@"default1"]options:SDWebImageRetryFailedcompleted:^(UIImage *image,NSError *error,SDImageCacheType cacheType,NSURL *imageUrl){
CGSize size = image.size;
CGFloat w = size.width;
CGFloat H = size.height;
}];

人已赞赏
iOS文章

Swift 静态多态与动态多态

2020-3-29 5:18:07

iOS文章

iOS 导入字体包

2020-3-29 6:33:05

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索