2012-02-29 28 views

回答

2

創建自定義Cell類

@interface CellView : UITableViewCell 
{ 
    UIImageView *img; 
    UILabel *lblTitle; 
} 
@property(nonatomic,retain)IBOutlet UIImageView *img; 
@property(nonatomic,retain)IBOutlet UILabel *lbl; 
@end 

而且在t他執行

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    CustCell *cell=(CustCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     NSArray *arr=[[NSBundle mainBundle] loadNibNamed:@"CustCell" owner:self options:nil]; 
     for (id idCell in arr){ 

      if([idCell isKindOfClass:[UITableViewCell class]]) 
      { 
       cell=(CustCell *) idCell; 
       break; 
      } 
     } 
    } 

    cell.lbl.text=[arrname objectAtIndex:indexPath.row]; 
    cell.img.image=[UIImage imageNamed:@"logo.jpg"]; 
    // Configure the cell. 
    return cell; 
} 
1

您可以添加一個子視圖到cell.contentView包含您的圖像的背景。 設置文字的顏色,你可以做

[cell.textLabel setTextColor: your_color]; 
0

//設置研究背景圖像

[cell setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Your Image"]]]; 

//設置文本顏色

[cell.textLabel setTextColor:[UIColor blueColor]]; 
相關問題