如何在tableViewCell中舍入UIImageView的courners

lad*_*kie 2 iphone cocoa-touch ios ios5

我试图让uiimagview在tableviewcell中使用以下代码进行圆角处理:

#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;
}
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,图像在tableViewCells中显示为空白.

如果我这样做cell.imageView.image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];(但没有圆角)它工作正常

我究竟做错了什么?

Vis*_*ode 10

你需要使用石英框架.这是转弯和添加边框到图像的代码

cell.imageView.layer.cornerRadius = 10.0;
cell.imageView.layer.borderColor = [UIColor blackColor].CGColor;

cell.imageView.layer.borderWidth = 1.2;
cell.imageView.clipsToBounds = YES;
Run Code Online (Sandbox Code Playgroud)

首先将图像设置为imageview,然后更改imageview图层