0

UITableViewのsectionIndexTitlesのデフォルトサイズを変更することは可能ですか? はいの場合、どのように?

4

2 に答える 2

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];

        }
    }

これは、必要に応じてカスタマイズできます。

于 2012-05-08T12:06:55.717 に答える
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セクションのタイトルを返す単純な関数を参照します。

于 2012-05-08T12:40:56.660 に答える