【发布时间】:2013-12-10 16:44:56
【问题描述】:
我正在努力设置 UIView Header 的样式,我正在使用 IOS7 故事板和自定义单元格 - 每个都有自己的类 -
我想用白色文本实现不透明的灰色背景 - Helvetica Neue Medium Font size 16 - 初始标题隐藏在 HeightForHeaderInSection 方法中 - 到目前为止我有 -
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
if (section == 0)
[headerView setBackgroundColor:[UIColor clearColor]];
else
[headerView setBackgroundColor:[UIColor colorWithRed:156.0f/255.0f green:156.0f/255.0f blue:156.0f/255.0f alpha:0.75f]];
[headerView setTintColor:[UIColor whiteColor]];
return headerView;
}
更新我的 Header 文本取自此方法 -
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger)section
{
if(section == 1)
{
return @"Offers";
}
else if(section == 2)
{
return @"Workouts";
}
else
{
return @"Weights";
}
}
【问题讨论】:
-
如何给headerView添加文字?
-
也许您应该将文本添加到
headerView?抱歉,我想我不明白这个问题。 -
对不起@llario - 在实施上述方法之前没有文本 - 它从数组中拉出并在我的 titleForHeaderInSection 方法中过滤 - 一旦我应用上述样式,它就看不见了
-
使用此代码如何传递文本?抱歉,我看不懂这段代码
-
在-cheers上方添加了titleforheader方法
标签: ios objective-c uitableview