Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9033455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:14:22+00:00 2026-06-16T08:14:22+00:00

I have UITableView which populates dates from the plist and Even Section’s Title is

  • 0

I have UITableView which populates dates from the plist and Even Section’s Title is been populated from plist in UITableView.it gives me the default blue section color and White text color.like this…

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {


NSString *key = nil;
if ([tableView isEqual:self.searchDisplayController.searchResultsTableView])
{
    key = [self.searchResults objectAtIndex:section];
}
else{
    key = [self.mySections objectAtIndex:section];
}

//    NSString *key = [self.mySections objectAtIndex:section];
return [NSString stringWithFormat:@"%@", key];

 }

.
Now I need to change this default text color and Section’s color, to do that I am implementing code shown below.But it gives me its own UIView.

-(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;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:14:23+00:00Added an answer on June 16, 2026 at 8:14 am

    To best customize the look of a table section header, you really need to implement two methods: the first one you already have, and it should work, albeit the results won’t be very usable.

    The second method is the tableView:heightForHeaderInSection:, which tells the UITableView what’s the height of the new section, and it can be as simple as this:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
        return 50.0f; 
    }
    

    EDIT: As per the comment, here’s the result of your code and defining the header height:

    final header label look

    EDIT 2: If you want red text with a black background, change your code for tableView:viewForHeaderInSection: like this:

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(0,200,300,244)];
        tempView.backgroundColor=[UIColor blackColor];
    
        UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0,300,44)];
        tempLabel.backgroundColor=[UIColor clearColor]; 
        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;
    }
    

    EDIT 3: Ok, so I’ll try to merge your code from the first method with the second one. It will look like this:

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(0,200,300,244)];
        tempView.backgroundColor=[UIColor blackColor];
    
        UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0,300,44)];
        tempLabel.backgroundColor=[UIColor clearColor]; 
        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];
    
        NSString *key = nil;
        if ([tableView isEqual:self.searchDisplayController.searchResultsTableView])
        {
            key = [self.searchResults objectAtIndex:section];
        }
        else{
            key = [self.mySections objectAtIndex:section];
        }
    
        tempLabel.text=[NSString stringWithFormat:@"%@", key];
        [tempView addSubview:tempLabel];
    
        [tempLabel release];
        return tempView;
    }
    

    This should return a table view section header with the proper label and proper look.

    EDIT 4: Just a note on how all of this works: if you use tableView:viewForHeaderInSection: whatever code you put in tableView:titleForHeaderInSection: will be ignored. So you need to do the whole setup of the section header, including the proper text in the tableView:viewForHeaderInSection method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Plist which is been populated on the tableview with expanded sections ..now
I have a UITableView which I want to populate with details from an array
I have a UITableView which is populated with an array of objects of type
I have a UITableView which is populated with some parsed JSON twitter data. The
I have an UITableview which has a description cell populated by an NSString ,
I have a plist that compiles a UITableView by the key Title, the plist
Upon completing the loading and displaying of a UITableView which has been correctly populated,
I have a UITableView populated by a SQLite database. I added Section-based Grouping using
I have a UITableView which downloads its tableviewcells images from a server. I observed
I have a UITableView which is populated by an array, I have a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.