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 8553849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:44:51+00:00 2026-06-11T14:44:51+00:00

I have three strings that I want to present in header of grouped tableview.

  • 0

I have three strings that I want to present in header of grouped tableview. Problem is I append this strings in tableView titleForHeaderInSection and I want to present each string in different line with different color and font.

What currently I have is :

enter image description here

What I want is:

enter image description here

I get and append those three string as following

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

    NSString * presenter = [[self agenda] getBriefingPresenter:section];
    NSString * time = [[self agenda] getBriefingTime:section];
    NSString * subject = [[[[self agenda] getMeetingBriefings] objectAtIndex:section] objectForKey:@"subject"];

    return [NSString stringWithFormat:@"%@\n%@  %@", subject, time, presenter ];

}

Method to handle the header font

- (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] init];
    label.frame = CGRectMake(45, 0, 484, 23);
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont fontWithName:@"Century Gothic" size:17];
    label.text = sectionTitle;
    label.lineBreakMode = UILineBreakModeWordWrap;
    label.numberOfLines = 2;
    [label sizeToFit];
    label.backgroundColor = [UIColor clearColor];

    // Create header view and add label as a subview
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 320, 400)];
    [view addSubview:label];

    return view;
}

So how can I parse this sectionTitle and print as three different labels in three lines?

  • 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-11T14:44:53+00:00Added an answer on June 11, 2026 at 2:44 pm

    In (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section, create 3 different labels with specific font and colors. You can’t set different fonts/colors on a single UILabel;

    So your code updated :

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
        NSString * presenter = [[self agenda] getBriefingPresenter:section];
        NSString * time = [[self agenda] getBriefingTime:section];
        NSString * subject = [[[[self agenda] getMeetingBriefings] objectAtIndex:section] objectForKey:@"subject"];
    
        // Create label with section title
        UILabel *presenterLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, 0, 484, 23)];
        presenterLabel.textColor = presenterColor;
        presenterLabel.font = presenterFont;
        presenterLabel.text = presenter;
        presenterLabel.backgroundColor = [UIColor clearColor];
        [presenterLabel sizeToFit];
    
        UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, presenterLabel.frame.size.height, 484, 23)];
        timeLabel.textColor = timeColor;
        timeLabel.font = timeFont;
        timeLabel.text = time;
        timeLabel.backgroundColor = [UIColor clearColor];
        [timeLabel sizeToFit];
    
        UILabel *subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(45, timeLabel.frame.origin.y + timeLabel.frame.size.height, 484, 23)];
        subjectLabel.textColor = subjectColor;
        subjectLabel.font = subjectFont;
        subjectLabel.text = subject;
        subjectLabel.backgroundColor = [UIColor clearColor];
        [subjectLabel sizeToFit];
    
    
        // Create header view and add label as a subview
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
        [view addSubview:presenterLabel];
        [view addSubview:timeLabel];
        [view addSubview:subjectLabel];
    
        return view;
    }
    

    and you don’t need the - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger) section

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

Sidebar

Related Questions

hey, this i have a loop that adds gathered strings and ints into an
I have a string that i need to split where there are 2 or
I have a method that effectively takes a string. However, there is a very
Let's say I have the following three strings: (section1){stuff could be any character, i
I have a list of strings in kumo . I am printing three strings.
I have three models: class User include Mongoid::Document field :name, :type => String has_many
I have the following code string three() { return three; } void mutate(string& ref)
I have these three lists with the same number of elements List<String>competitoinsIDs = new
i have many urls(string): $one = 'http://www.site.com/first/1/two/2/three/3/number/342'; $two = '/first/1/two/2/number/32'; $three = 'site.com/first/1/three/3/number/7'; $four
I have declared a DLL import in my C# program that looks like this:

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.