1、直接获取
NSData*data = [NSDatadataWithContentsOfURL:[NSURLURLWithString:@"http://s12.mogujie.cn/b7/bao/131011/1jix9_kqywmrcdkfbg26dwgfjeg5sckzsew_400x540.jpg_200x999.jpg"]];
UIImage*image = [UIImageimageWithData:data];
NSLog(@"w = %f,h = %f",image.size.width,image.size.height);
2、//需要用到第三方库SDWebImage
UIImageView*v1 = [[UIImageViewalloc]init];
[self.viewaddSubview:v1];
[v1sd_setImageWithURL:[NSURLURLWithString:imageNameplaceholderImage:[UIImageimageNamed:@"default1"]options:SDWebImageRetryFailedcompleted:^(UIImage*image,NSError*error,SDImageCacheTypecacheType,NSURL*imageUrl){
CGSizesize = image.size;
CGFloatw = size.width;
CGFloatH = size.height;
}];
网友评论