rounded image using SDWebImage

I want to use SDWebImage in my code to use cache with my images but I want to use rounded images.

With this code I have rounded images and works perfect:

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

But I need to use SDWebImage and cache too so I have this code:

[cell.imageView setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed:@"placeholder.png"] ];

I want to know how I merge the codes to use SDWebImage and rounded image.

I tried this code but not worked:

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

Answers


Try this: Replace your code

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

with below code And Import "QuartzCore/QuartzCore.h" Framework

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

Need Your Help

What's the best way to detect web applications attacks?

security web-applications exploit denial-of-service

What is the best way to survey and detect bad users behavior or attacks like deny of services or exploits on my web app ?

foreach vs someList.ForEach(){}

c# .net generics loops enumeration

There are apparently many ways to iterate over a collection. Curious if there are any differences, or why you'd use one way over the other.