I’m trying to have the uiimagview have rounded corners in a tableviewcell with this code:
#import <QuartzCore/QuartzCore.h>
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HomepwnerItemCell *cell = (HomepwnerItemCell *)[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
Possession *possession = [self.possessions objectAtIndex:indexPath.row];
cell.valueLabel.text = [@"$" stringByAppendingString:[[NSNumber numberWithInt:possession.valueInDollars] stringValue]];
cell.nameLabel.text = possession.possessionName;
UIImage *image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];
UIImageView *roundedImage = [[UIImageView alloc] initWithImage:image];
roundedImage.layer.masksToBounds = YES;
roundedImage.layer.cornerRadius = 10.0;
cell.imageView = roundedImage;
// cell.imageView.image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];
return cell;
}
but the images show up blank in the tableViewCells when I run it.
it works fine if I just do cell.imageView.image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey]; (but without the rounded corners)
What am I doing wrong?
YOu need to use the quartz framework. Here is the code for cornering and adding border to image
First Set Image to imageview, then change the imageview layer