【发布时间】:2013-07-28 20:59:13
【问题描述】:
所以我有这个包含几个部分的 Tableview,确切地说是 (3)。我希望第 2 节和第 3 节有标题,而不是第一节..
这是我所做的:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionName;
UIView *tempView;
tempView = [[UIView alloc]initWithFrame:CGRectMake(0,0,300,20)];
tempView.backgroundColor=[UIColor grayColor];
UILabel *tempLabel = [[UILabel alloc]initWithFrame:CGRectMake(10,0,300,20)];
tempLabel.backgroundColor = [UIColor clearColor];
tempLabel.shadowColor = [UIColor blackColor];
tempLabel.shadowOffset = CGSizeMake(0,2);
tempLabel.textColor = [UIColor whiteColor]; //here you can change the text color of header.
tempLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0f];
switch (section)
{
break;
case 1:
{
sectionName = NSLocalizedString(@"Information", @"Information");
tempLabel.text = sectionName;
[tempView addSubview:tempLabel];
}
break;
case 2:
{
sectionName = NSLocalizedString(@"Tools", @"Tools");
tempLabel.text = sectionName;
[tempView addSubview:tempLabel];
}
break;
}
return tempView;
}
我对需要做什么感到困惑......这是正在发生的事情的图片:
【问题讨论】:
标签: iphone ios objective-c uitableview tableview