I'm trying to make an app that has images in a rounded imageView but with images of different and varying sizes. My goal is to have a small piece of the image appear if the image is too big (so the image doesn't look distorted).
I'm able to get rounded imageView but it's alway different sizes for different images--which is not what I want. I read the posts here:
Using cornerRadius on a UIImageView in a UITableViewCell
Some of my code is here for the UITableViewCell (which I subclassed):
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
// [self.imageView setContentMode:UIViewContentModeScaleAspectFill];
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.bounds = CGRectMake(0, 0, 44,44);
self.imageView.frame = CGRectMake(5, 10, 44, 44);
CGRect frame = self.imageView.frame;
self.imageView.layer.cornerRadius = 15;
[self.imageView.layer setMasksToBounds:YES];
self.imageView.clipsToBounds = YES;
}
return self;
}
I'm using SDWebImage
to load the image. Is there anything else i'm missing here?