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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:47:09+00:00 2026-06-08T21:47:09+00:00

I have a title that I put into a UILabel. I get it to

  • 0

I have a title that I put into a UILabel. I get it to wrap the text just fine onto two lines, but often the second line just has one small word in it. Is there a way to tell the system to wrap the lines a little more evenly?

The titles are dynamically fetched, so I don’t believe I can have this determined ahead of time.

  • 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-08T21:47:11+00:00Added an answer on June 8, 2026 at 9:47 pm

    You could figure out what the length would be on a single line, then take that width, divide by 2, and use that result as the width constraint for a 2 line label. That would perhaps get you a better visual result, but you might have to tweak this a little if you have long words that would cause your label to be 3 lines (unless more than 2 lines is ok).

    This approach has the disadvantage of doing a little extra work, but it might do the trick. For example:

        NSString *text = @"This is my very long title I want evenly on 2 lines";
        UILabel *theLabel = [[UILabel alloc] init];
        theLabel.text = text;
        // ...other label setup here, like font, etc
        [theLabel sizeToFit];
    
        CGSize constraint = CGSizeMake(theLabel.frame.size.width / 2.0, 1000);
        CGSize labelSize = [theLabel.text sizeWithFont:theLabel.font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
    
        theLabel.numberOfLines = 0;
        theLabel.lineBreakMode = UILineBreakModeWordWrap;
        CGRect frame = theLabel.frame;
        frame.size = labelSize;
        theLabel.frame = frame;
    

    That should do it. Warning: Written from memory. 🙂

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

Sidebar

Related Questions

I have a text title that reads This User The Title Of The Post
I'm not sure how to put this best into a title, but this is
I think the title is clear, but I will elaborate. I have two websites
I have a UIbutton title that I set with [[buttons objectAtIndex:selectedButtonTag] setTitle:file forState:UIControlStateNormal]; This
I have in a sidebar: <div id=yyy> [shortcode]</div> It outputs a title that when
That title is presumably awfully worded. I have some PostgreSQL tables. There is a
I am trying to show only elements that have the title attribute passed to
As in title I have a page that calls a lot of webservices through
(I realize that my title is poor. If after reading the question you have
I have it currently so that my post title links to an external URL

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.