在我的应用程序中,我有一个表格视图,迄今为止我已经使用故事板(我添加了部分:行:单元格等等,所有通过故事板),我编程的唯一更改是将UIButton
添加为通过实施部分标题之一:如何添加带有下标的表格视图节标题?
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section == 2) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 64)];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button1 setTitle:@"Hydro Volume" forState:UIControlStateNormal];
button1.frame = CGRectMake(62.5, 5, 205, 44);
[view addSubview:button1];
[button1 addTarget: self
action: @selector(buttonClicked:)
forControlEvents: UIControlEventTouchDown];
return view;
}
return nil;
}
我现在的困境是,我需要添加一个节标题包含标,即:H2O
我无法干脆直接添加标中故事板检查员,有人能告诉我怎么做到这一点?
我回顾了this question,但它不是我正在寻找的,因为我需要能够将它添加到我的部分标题中。
UILabel有一个'属性文字'属性,它接受'NSAttributedString'。那么,你的section标题视图是一个UILabel(或者一个包含UILabel的视图)和属性文本? –
@esker你会介意给我一些这样的示例代码吗? – vzm