iPhone UITableViewCell: repositioning the textLabel

前端 未结 5 2028
终归单人心
终归单人心 2020-12-25 12:00

I am new to iPhone development and I am currently working on a simple RSS reader app. The problem I am having is that I need to reposition the textLabel inside

5条回答
  •  离开以前
    2020-12-25 12:23

    Seems I solved my own problem. Here's some code, in case someone runs into the same problem:

    UILabel *ttitle = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 20)] autorelease];
    ttitle.font = [UIFont boldSystemFontOfSize:13];
    ttitle.textColor    = [UIColor blackColor];
    ttitle.textAlignment = UITextAlignmentLeft;
    
    [ttitle setText:[[stories objectAtIndex: storyIndex] objectForKey: @"title"]];
    
    [cell.contentView addSubview:ttitle];
    

    The idea is to create your own label object, because the textLabel is automatically positioned and can't be moved around.

    Cheers.

提交回复
热议问题