Use below method to get a Rounded corner image with the specified radius for rounded corner, apply all your above properties as UIViewContentModeScaleAspectFit
, clip to bounds e.t.c. on image view and set the received image by calling below function on the image view.
-(UIImage *)makeRoundedImage:(UIImage *) image
radius: (float) radius;
{
CALayer *imageLayer = [CALayer layer];
imageLayer.frame = CGRectMake(0, 0, image.size.width, image.size.height);
imageLayer.contents = (id) image.CGImage;
imageLayer.masksToBounds = YES;
imageLayer.cornerRadius = radius;
UIGraphicsBeginImageContext(image.size);
[imageLayer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return roundedImage;
}
Call as
UIImage *image = [self makeRoundedImage:[UIImage imageNamed:@"accept~iphone"]
radius: 5.0f];
cell.imgvAlbum.contentMode = UIViewContentModeScaleAspectFit;
cell.imgvAlbum.clipsToBounds = YES;
cell.imgvAlbum.layer.cornerRadius = 5.0f;
cell.imgvAlbum.layer.masksToBounds = YES;
[cell.imgvAlbum setImage: image];
AspectFit
, the image doesn't fill the image view. To get the effect you want you will need to resize the image view based on the aspect ratio of the image. – Niigata