una tamaño predeterminado predeterminada power poner letra fuente formato como cambiar iphone ios uitableview fonts textcolor

iphone - tamaño - formato predeterminado word



¿Cómo podemos cambiar la fuente del encabezado de la vista de tabla? (5)

Estoy usando un poco de color de fondo para tabelView y el estilo está agrupado. El texto en el encabezado de las secciones no está claro, así que necesito modificar el color del texto para que el texto del encabezado esté visible. Quiero saber si podemos cambiar el color y el tamaño del texto del encabezado.


Agregando a la respuesta de terente:

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 0) { CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; UIView* headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenRect.size.width, 44.0)]; //headerView.contentMode = UIViewContentModeScaleToFill; // Add the label UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0, -5.0, 300.0, 90.0)]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.opaque = NO; headerLabel.text = @"Header"; headerLabel.textColor = [UIColor blackColor]; headerLabel.highlightedTextColor = [UIColor blackColor]; //this is what you asked headerLabel.font = [UIFont boldSystemFontOfSize:17]; headerLabel.shadowColor = [UIColor clearColor]; headerLabel.shadowOffset = CGSizeMake(0.0, 1.0); headerLabel.numberOfLines = 0; headerLabel.textAlignment = UITextAlignmentCenter; [headerView addSubview: headerLabel]; [headerLabel release]; // Return the headerView return headerView; } else return nil; }

Puede usar [UIFont fontWithName:@"<name of your font>" size:24.0]; para otras fuentes


Solo implemente

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

Y devuelva su vista personalizada para el encabezado.

Editar:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIImageView *headerTitleView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, kSectionHeaderHeight)]; [headerTitleView setImage:sectionHeaderBackgroundImage]; UILabel *sectionTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 38) / 2, 5, 38, kSectionHeaderHeight - 10)]; sectionTitleLabel.textColor = [UIColor redColor]; sectionTitleLabel.backgroundColor = [UIColor clearColor]; sectionTitleLabel.textAlignment = UITextAlignmentCenter; sectionTitleLabel.text = @"A"; sectionTitleLabel.font = [UIFont fontWithName:@"yourFont" size:13]; [sectionTitleLabel setAdjustsFontSizeToFitWidth:YES]; [headerTitleView addSubview:sectionTitleLabel]; return headerTitleView; }


- (void) tableView : (UITableView*) tableView willDisplayHeaderView : (UIView*) view forSection : (NSInteger) section{ [((UITableViewHeaderFooterView) *view).textLabel setFont:(UIFont...)]; }

y puede establecer la etiqueta de texto desde el otro método delegado de vista de tabla.


- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section { [((UITableViewHeaderFooterView *) view).textLabel setFont:[UIFont fontWithName:@"Your-Font-Name" size:((UITableViewHeaderFooterView *) view).textLabel.font.pointSize]]; }


Notas:

  • Esto configurará la fuente en una fuente personalizada, pero mantendrá el mismo pointSize .
  • También funciona para willDisplayFooterView .
  • No olvides cambiar Your-Font-Name a tu fuente.

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section { if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) { UITableViewHeaderFooterView *headerView = (UITableViewHeaderFooterView*)view; [headerView.textLabel setFont:[UIFont fontWithName:@"Gotham Book" size:16.0f]]; }}

Podemos usar el objeto header.textlabel para cambiar otras propiedades "UILabel" para esa etiqueta.