0

我正在重新使用 Apple 的AdvancedTableViewCells示例来创建自定义的快速滚动表格视图。具体来说,我正在使用他们的CompositeSubviewBasedApplicationCell方法在 tableviewcell 上绘制内容drawRect

一切正常,但是如何使用他们的方法隐藏标签或设置标签或图像的标签?这样做对我来说很新(没有 IB),所以如果这很容易,我提前道歉。

设置单元格内容的代码是:

- (void)drawRect:(CGRect)rect
{

[_cell.animalIcon drawAtPoint:CGPointMake(5.0, 5.0)];

[_cell.animalName drawAtPoint:CGPointMake(93.0, 25.0)];

_highlighted ? [[UIColor whiteColor] set] : [[UIColor colorWithWhite:0.23 alpha:1.0] set];
[_cell.animalDescription drawAtPoint:CGPointMake(100.0, 54.0) withFont:[UIFont boldSystemFontOfSize:13.0]];

[_cell.animalNameString drawAtPoint:CGPointMake(93.0, 5.0) withFont:[UIFont boldSystemFontOfSize:13.0]];

}
4

1 回答 1

1

tag并且hidden是 的属性UIView。由于您不再处理 UIView 的实例(您没有 UILabel 或 UIImageView,只有 NSString 或 UIImage),因此它们没有tag属性。如果要隐藏文本的特定部分,请不要将其绘制在drawRect:. 使用简单的 if 语句来测试确定是否应绘制文本所需的任何条件。

于 2010-06-06T20:11:28.640 回答