UITableView将文本置于图像顶部

UITableView将文本置于图像顶部,uitableview,cell,Uitableview,Cell,我有一个UITableView,每个单元格上都有一个图像和文本,但是它们并排放置。我要做的是把文本标签放在图像的顶部。有可能吗?您必须定义一个自定义的UITableViewCell,您可以在其中放置任何标准的UI对象,包括UILabel在UIImage上的UILabel使用自定义的UITableViewCell,其中,在每个单元格上取UIView,将图像作为UIView的背景色,然后在UIView顶部取一个UILabel - (UITableViewCell *)tableView:(UITab

我有一个
UITableView
,每个单元格上都有一个图像和文本,但是它们并排放置。我要做的是把文本标签放在图像的顶部。有可能吗?

您必须定义一个自定义的
UITableViewCell
,您可以在其中放置任何标准的UI对象,包括
UILabel
UIImage
上的
UILabel
使用自定义的
UITableViewCell
,其中,在每个单元格上取
UIView
,将图像作为
UIView
的背景色,然后在
UIView
顶部取一个
UILabel

- (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];

}