2012-05-08 64 views

回答

0
for(UILabel *aView in [tableView subviews]) 
    { 
     NSLog(@"frame:%@",aView); 
     if([[[aView class] description] isEqualToString:@"UITableViewIndex"]) 
     { 

      aView.font=[UIFont fontWithName:@"Helvetica-Bold" size:18.0]; 

     } 
    } 

您可以根據自己的需要進行定製。

+0

我在問如何更改大小?我應該在changeSectionIndexTitleSize裏面實現什麼? –

+0

嗨,我只是想知道如果直接訪問UITableViewIndex是否被蘋果拒絕? – slik

1

您需要實現

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 

在你的UITableViewDelegate描述here

下面是一個例子:

- (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指的是一個簡單的函數返回的部分標題。

相關問題