2011-09-29 105 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細胞的標籤。希望它有幫助...