Iphone 如何更改UITableView中SectionIndexTitles的大小?
有谁能告诉我,是否可以在UITableView中更改sectionIndexTitles的默认大小?如果是,那怎么办Iphone 如何更改UITableView中SectionIndexTitles的大小?,iphone,objective-c,ios4,xcode4.2,Iphone,Objective C,Ios4,Xcode4.2,有谁能告诉我,是否可以在UITableView中更改sectionIndexTitles的默认大小?如果是,那怎么办 for(UILabel *aView in [tableView subviews]) { NSLog(@"frame:%@",aView); if([[[aView class] description] isEqualToString:@"UITableViewIndex"]) { a
for(UILabel *aView in [tableView subviews])
{
NSLog(@"frame:%@",aView);
if([[[aView class] description] isEqualToString:@"UITableViewIndex"])
{
aView.font=[UIFont fontWithName:@"Helvetica-Bold" size:18.0];
}
}
您可以根据自己的需要进行定制。您需要实施
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
在UITableViewDelegate中,如所述
下面是一个例子:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *headerView = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 60)] autorelease];
[headerView setBackgroundColor:[UIColor clearColor]];
UILabel * headerLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 60)];
[headerLabel setBackgroundColor:HEXCOLOR(0x952039FF)];
[headerLabel setTextColor:[UIColor whiteColor]];
[headerLabel setShadowColor:[UIColor grayColor]];
CGRect frame = headerLabel.frame;
frame.origin = CGPointMake(20,frame.origin.y);
headerLabel.frame = frame;
[headerLabel setText:[self sectionTitles:section]];
[headerView addSubview:headerLabel];
[headerLabel release];
return headerView;
}
sectionTitles
是一个返回节标题的简单函数。我在问如何更改大小?我应该在changeSectionIndexTitleSize内部实现什么?嗨,我只是想知道,如果直接访问UITableViewIndex,苹果会拒绝它吗?你不能更改大小。自定义索引的唯一解决方案是创建自己的AFAIK