2012-02-29 17 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]]; 
相关问题