2012-01-09 82 views

回答

3

采取定制UITableViewCell,其中采取UIView在每一个细胞,使你的形象为UIView的背景颜色,然后采取UILabelUIView的顶部。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *MyIdentifier = @"MyIdentifier"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; 
    cell.textLabel.font = [UIFont fontWithName:@"Arial" size:15.0]; 
    cell.selectionStyle = UITableViewCellSelectionStyleBlue; 

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pl_arows.png"]]; 
    cell.accessoryView = imageView; 
    cellView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,290, 70)] autorelease]; //important do not changer the position 
    cellView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"order_description_bg.png"]]; 
    cellView.tag =10; 
    [cell.contentView addSubview:cellView]; 

    imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 15, 39, 36)]; 
    imgView.image = [UIImage imageNamed:@"image_category.png"]; 
    imgView.layer.borderColor = [UIColor blackColor].CGColor; 
    imgView.tag = 5; 
    [cellView addSubview:imgView]; 

    //Status label 

      CGRect statusRectText = CGRectMake(52, 0, 50, 18); 
    UILabel *statusLabelText = [[[UILabel alloc] initWithFrame:statusRectText] autorelease]; 
    statusLabelText.textAlignment = UITextAlignmentRight; 
      statusLabelText.backgroundColor = [UIColor clearColor]; 
    statusLabelText.tag = 101; 
    [imgView addSubview:statusLabelText]; 

} 
+0

非常感谢,这完全有帮助, – Spriggsy 2012-01-10 15:01:04

2

您必须定义一个自定义UITableViewCell,您可以在其中放置任何标准UI对象,包括在您的UIImage之上。