문제

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];
도움이 되었습니까?

해결책

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"] ];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top