2013-11-21 61 views
0

我想在我的代碼中使用SDWebImage以使用緩存與我的圖像,但我想使用舍入的圖像。使用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]; 

回答

2

試試這個: 替換代碼

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"] ]; 

與下面的代碼和進口 「QuartzCore/QuartzCore.h」 框架

cell.imageView.backgroundColor=[UIColor clearColor]; 
[cell.imageView.layer setCornerRadius:30]; 
[cell.imageView.layer setMasksToBounds:YES]; 
[cell.imageView setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:  [UIImage imageNamed:@"placeholder.png"] ]; 
+0

謝謝...代碼的工作 – eugui