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];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容