texto tamaño poner para pages oficio mover mac lugar letra hoja cual como color cambiar iphone objective-c cocoa-touch uitableview ios4

tamaño - ¿Cómo cambiar el color del texto para los encabezados de sección en un TableView agrupado en iPhone SDK?



hoja tamaño oficio en mac (7)

Agregue el siguiente código a su clase AppDelegate en - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions método - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions :

[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setTextColor:[UIColor whiteColor]];

Estoy creando una aplicación para iPhone en la que tengo un TableView agrupado con encabezados para las secciones.

El problema es que quiero cambiar el color del texto del encabezado de sección.

¿Cómo puedo cambiar el color del texto del encabezado de sección?

¿Qué tengo que hacer?


Construí a partir de la respuesta de @Harsh.

Esto es lo más cerca que puedo estar, indistinguible de lo que puedo decir.

Va en el <UITableViewDataSource> obviamente.

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *hView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; hView.backgroundColor=[UIColor clearColor]; UILabel *hLabel=[[[UILabel alloc] initWithFrame:CGRectMake(19,17,301,21)] autorelease]; hLabel.backgroundColor=[UIColor clearColor]; hLabel.shadowColor = [UIColor whiteColor]; hLabel.shadowOffset = CGSizeMake(0.5,1); // closest as far as I could tell hLabel.textColor = [UIColor blackColor]; // or whatever you want hLabel.font = [UIFont boldSystemFontOfSize:17]; hLabel.text = @"Your title here"; // probably from array [hView addSubview:hLabel]; return hView; }


Esto seguramente va a funcionar para usted.

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(0,200,300,244)]; tempView.backgroundColor=[UIColor clearColor]; UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0,300,44)]; tempLabel.backgroundColor=[UIColor clearColor]; tempLabel.shadowColor = [UIColor blackColor]; tempLabel.shadowOffset = CGSizeMake(0,2); tempLabel.textColor = [UIColor redColor]; //here you can change the text color of header. tempLabel.font = [UIFont fontWithName:@"Helvetica" size:fontSizeForHeaders]; tempLabel.font = [UIFont boldSystemFontOfSize:fontSizeForHeaders]; tempLabel.text=@"Header Text"; [tempView addSubview:tempLabel]; [tempLabel release]; return tempView; }

simplemente copia y pega esta función en tu código.


La respuesta de @Harsh funcionó muy bien para mí, y al cambiar las coordinaciones de UILabel puede moverla. Además, yo, personalmente, pensé en cambiar un poco la sombra para hacerlo más legible, pero eso podría ser una elección personal. Aquí está mi versión en caso:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section]; if (sectionTitle == nil) { return nil; } // Create label with section title UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(40, -5, 300, 30)] autorelease]; //If you add a bit to x and decrease y, it will be more in line with the tableView cell (that is in iPad and landscape) label.backgroundColor = [UIColor clearColor]; label.textColor = [UIColor yellowColor]; label.shadowColor = [UIColor whiteColor]; label.shadowOffset = CGSizeMake(0.5., 0.5.); label.font = [UIFont boldSystemFontOfSize:18]; label.text = sectionTitle; // Create header view and add label as a subview UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, SectionHeaderHeight)]autorelease]; [view addSubview:label]; return view; }


Puede implementar este método de fuente de datos de vista de tabla:

- (UIView *)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section { //create your custom label here & anything else you may want to add return YourCustomView; }


Si no quieres hacerlo en una aplicación tan amplia como en la solución de Vahan, aquí hay una solución que utiliza uno de los UITableViewDelegate de UITableViewDelegate :

func tableView(tableView: UITableView, willDisplayHeaderView view:UIView, forSection: Int) { if let headerView = view as? UITableViewHeaderFooterView { headerView.textLabel?.textColor = UIColor.redColor() } }


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel *myLabel = [[UILabel alloc] init]; myLabel.frame = CGRectMake(20, 8, 220, 20); myLabel.font = [UIFont boldSystemFontOfSize:16]; myLabel.text = [self tableView:tableView titleForHeaderInSection:section]; myLabel.backgroundColor=[UIColor grayColor]; UIView *headerView = [[UIView alloc] init]; [headerView addSubview:myLabel]; return headerView; }