【发布时间】:2014-06-30 05:00:32
【问题描述】:
我正在尝试像这样在 cellforrowatindexpath 中圆角图像:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSString *identifiers = _identifiers[indexPath.row];
if([identifier isEqualToString:@"bronze"]){
cell.imageView.image = [UIImage imageNamed:@"bronze.png"];
cell.imageView.layer.cornerRadius = cell.imageView.frame.size.width / 2;
cell.imageView.clipsToBounds = YES;
}
return cell;
}
但是,这不起作用。我做错了什么?
【问题讨论】:
-
你的目标是什么?要在图像周围绘制轮廓(如果您使用 Michael 的设置borderWidth 和borderColor 的建议,您会感到很奇怪)或者您是否尝试裁剪掉图像的角落?
-
我正在尝试裁剪掉角落并制作一个图像的圆圈。这适用于我的代码中的其他地方,只是不适用于 celforrow
-
您是否在
if中设置了断点?你确定代码真的被执行了吗?角半径设置为哪个实际值?如果将NSLog(@"in bronze. radius=%.1f", (float)(cell.imageView.frame.size.width / 2));放入 if 中,会打印什么? -
你的问题和 Cocoa 有什么关系?
-
@ElTomato 是的,应该是 cocoa-touch...
标签: ios objective-c uitableview cocoa-touch uiimageview