IOS-在静态UITableViewController中设置节标题的样式-IOS7
是否可以在静态UITableViewController中设置节标题背景/字体样式?我看不到任何脚本选项可以执行此操作,并且由于表是静态的,因此表方法在.M文件中已被禁用-因此我也不确定如何以编程方式应用样式设置?UITableViewDelegate协议定义了一个方法viewForHeaderInSection,该方法可在代理中实现,以返回自定义标题视图(也适用于静态UITableView)。例如:IOS-在静态UITableViewController中设置节标题的样式-IOS7,ios,objective-c,uitableview,Ios,Objective C,Uitableview,是否可以在静态UITableViewController中设置节标题背景/字体样式?我看不到任何脚本选项可以执行此操作,并且由于表是静态的,因此表方法在.M文件中已被禁用-因此我也不确定如何以编程方式应用样式设置?UITableViewDelegate协议定义了一个方法viewForHeaderInSection,该方法可在代理中实现,以返回自定义标题视图(也适用于静态UITableView)。例如: 是,为标题部分实现视图 - (UIView *)tableView:(UITableView
是,为标题部分实现视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
// you can get the title you statically defined in the storyboard
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
// create and return a custom view
UILabel *customLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 50.0f)];
customLabel.text = sectionTitle;
return customLabel;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
// return a custom height here if necessary
return 50.0f;
}