在iOS7上进行转换时,分隔符左侧有15px填充.我知道我可以在xib文件中的UITableView设置中使用分隔符插入功能删除此填充,但我需要使用填充保持标题文本.怎么做?
默认:
使用自定义分隔符插入0:

我需要像图2那样保留分隔符,但标题为"2013",如图1所示.
我知道这是一个菜鸟问题,但是...我在桌面视图上有这些标签,但文字完全被压到了左边.我想添加一些填充.我该怎么办呢?
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView* customView = [[[UIView alloc] initWithFrame:CGRectMake(10,0,300,60)] autorelease];
UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
headerLabel.backgroundColor = [UIColor colorWithHexString:[[_months objectAtIndex:section] objectForKey:@"color"]];
headerLabel.font = [UIFont boldSystemFontOfSize:18];
headerLabel.frame = CGRectMake(0,0,400,30);
headerLabel.text = [[_months objectAtIndex:section] objectForKey:@"name"];
headerLabel.textColor = [UIColor whiteColor];
[customView addSubview:headerLabel];
return customView;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢!谢谢!
如何向 UITableView 单元格中的节标题添加一些填充?
我有这个:

我有一个 NSDictionary,其键值包含一串时间。我将键值存储在 NSArray 中。
我使用 titleForHeaderInSection 而不是 viewForHeaderInSection。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [schedule objectAtIndex:section];
}
Run Code Online (Sandbox Code Playgroud)
但是,节标题始终向左对齐。我可以使用 viewForHeaderInSection 的 UIView 将其填充到我喜欢的位置,但是有什么方法可以为方法 titleForHeaderInSection 做到这一点吗?