2011-09-29 108 views
3

我已经成功地制作了一个使用UITableView的iPhone应用程序。我想开始为应用增加一些生活。我如何定制表格?例如,更改单元格的高度,将自定义图像添加到单元格,颜色等等。...自定义UITableView

任何好的建议?

回答

1
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier]; 

if(cell == nil) 
{ 

    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
    cell.selectionStyle = UITableViewCellSelectionStyleNone; 

    UILabel *label; 

    label = [[[UILabel alloc] initWithFrame:CGRectMake(5, 0.5, 240.0, 25.0)] autorelease]; 
    label.tag = WHAT_TAG; 
    label.font = [UIFont boldSystemFontOfSize:14.0]; 
    label.textAlignment = UITextAlignmentLeft; 
    label.textColor = [UIColor blueColor]; 
    label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; 
    label.backgroundColor = [UIColor clearColor]; 
    [cell.contentView addSubview:label]; 

} 

刚刚尝试这种使用标签覆盖表格单元格,并通过自定义,你可以自定义TABEL细胞的标签。希望它有帮助...