SDWebImg 获取图片尺寸根据屏幕高度自适应

            UIImageView *img=[[UIImageView alloc]initWithFrame:frame(20, 20, 710, 340)];
            WS(weakself)
            [img sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://f.ishareonline.cn/activity/7827d6bd30d1401e8f02c18de0300e69.jpg"]] placeholderImage:nil options:(SDWebImageRetryFailed) completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
                CGSize size=image.size;
                float proportion=(weakself.view.frame.size.width-20)/size.width;//根据屏幕大小算出比例
                img.frame = CGRectMake(10, 10, image.size.width*proportion, image.size.height*proportion);
                _height=img.size.height+20;
                if (dataGo==0) {
                    dataGo=1;
                     [_tablView reloadData];
                }
            }];
            [cell.contentView addSubview:img];

你可能感兴趣的:(SDWebImg 获取图片尺寸根据屏幕高度自适应)