iOS:viewForHeaderInSection无法与单元格对齐?

时间:2012-03-09 22:48:43

标签: ios uitableview

我的viewForHeaderInSection:tableViewController

中有这段代码
 UILabel *l = [[[UILabel alloc] initWithFrame:CGRectMake(20, 0, 320, 40)] autorelease];
  l.backgroundColor = [UIColor clearColor];
  //l.textAlignment = UITextAlignmentLeft; //i tried it didn't help!
  l.text= NSLocalizedString(@"My Label:", @"");

标签总是出现在细胞左侧35点附近。如果我使用UITextAlignmentCenter它工作,它进入中心,但我希望它与单元格的左侧大小对齐。我尝试了CGRectZero而不是CGRectMake(20,0,320,40),更改了x但它没有用!

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

首先使用框架(0,0,320,40)进行视图。然后在上面贴上标签。

相关问题