如何圆一个UIImageView的courners在tableViewCell
问题描述:
我想有uiimagview与该代码tableviewcell已圆角:如何圆一个UIImageView的courners在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;
}
但图像显示为空白的tableViewCells当我运行。
它工作正常,如果我只是做cell.imageView.image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];
(但没有圆角)
我在做什么错?
答
你需要使用石英框架。这里是一个转弯和添加边框图像的代码
cell.imageView.layer.cornerRadius = 10.0;
cell.imageView.layer.borderColor = [UIColor blackColor].CGColor;
cell.imageView.layer.borderWidth = 1.2;
cell.imageView.clipsToBounds = YES;
第一组图像,以imageview的,然后更改的ImageView层
答
使用
cell.imageView.layer.cornerRadius=20; //Use as ur specified corner length
还实现
<QuartzCore/QuartzCore.h>
细胞.imageView = [roundedImage图像];尝试这个。 – Sarah 2011-12-29 05:25:14
错误:自动引用计数问题:实例消息的接收器类型'UIImageView'没有声明具有选择器'Image'的方法 – ladookie 2011-12-29 05:27:59
检查UIImage *图像是否分配了内存? – Sarah 2011-12-29 05:43:09