2012-01-09 77 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之上。