【发布时间】:2013-11-21 23:58:08
【问题描述】:
我想在我的代码中使用 SDWebImage 来对我的图像使用缓存,但我想使用圆形图像。
使用此代码,我可以对图像进行四舍五入并且效果很好:
NSString *imageURL = [noticia objectForKey:@"imagem"];
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(20, 5, 90, 70)];
imgView.backgroundColor=[UIColor clearColor];
[imgView.layer setCornerRadius:30];
[imgView.layer setMasksToBounds:YES];
[imgView setImageWithURL:[NSURL URLWithString:imageURL]];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
[cell.contentView addSubview:imgView];
但我也需要使用 SDWebImage 和缓存,所以我有这个代码:
[cell.imageView setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed:@"placeholder.png"] ];
我想知道如何合并代码以使用 SDWebImage 和圆形图像。
我尝试了这段代码,但没有成功:
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(20, 5, 90, 70)];
imgView.backgroundColor=[UIColor clearColor];
[imgView.layer setCornerRadius:30];
[imgView.layer setMasksToBounds:YES];
[imgView setImageWithURL:[NSURL URLWithString:imageURL]];
[cell.imageView setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed:@"placeholder.png"] ];
[cell.contentView addSubview:imgView];
【问题讨论】: