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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:10:16+00:00 2026-05-25T02:10:16+00:00

I have a UILabel, his text size has the property title.adjustsFontSizeToFitWidth = YES; that

  • 0

I have a UILabel, his text size has the property

title.adjustsFontSizeToFitWidth = YES;

that prevents me from using standard methods to resize the UILabel. I read on another post here that I’m supposed to use the function

sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode

from this answer: How to figure out the font size of a UILabel when -adjustsFontSizeToFitWidth is set to YES?

Now, i can’t figure out how to make it work.. this is the actual code

UIFont *font = [UIFont fontWithName:@"Marker Felt" size:200];
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, width, 20.0)];
title.text = @"this is a long title that should be resized";
title.font = font;
title.numberOfLines = 1;
title.adjustsFontSizeToFitWidth = YES;

CGFloat pointSize = 0.0;
CGSize size = [title.text sizeWithFont:font 
                           minFontSize:title.minimumFontSize 
                        actualFontSize:&pointSize 
                              forWidth:width 
                         lineBreakMode:title.lineBreakMode];
title.frame = CGRectMake(title.frame.origin.x, 
                         title.frame.origin.y, 
                         size.width, 
                         size.height);

The UILabel get resized wrongly, as if the font size it’s still 200..
Any clues? Thanks!

  • 1 1 Answer
  • 1 View
  • 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-05-25T02:10:17+00:00Added an answer on May 25, 2026 at 2:10 am

    I’d suggest filing this as a bug.

    The size returned by -sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode: has the correct width, but not the height does not account for the actual font size.

    It seems likely that UILabel also has this bug. Changing the size of a label to match the height of the text in a font of the size returned by -sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode: will incorrectly vertically position the text within the label.

    A work-around is to calculate the correct height, and change the font on the label to with the actual font size:

    CGFloat pointSize = 0.0f;
    CGRect frame = title.frame;
    frame.size = [title.text sizeWithFont:font
                              minFontSize:title.minimumFontSize
                           actualFontSize:&pointSize
                                 forWidth:width
                            lineBreakMode:title.lineBreakMode];
    UIFont *actualFont = [UIFont fontWithName:@"Marker Felt" size:pointSize];
    CGSize sizeWithCorrectHeight = [title.text sizeWithFont:actualFont];
    frame.size.height = sizeWithCorrectHeight.height;
    title.frame = frame;
    title.font = actualFont;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UILabel with right-aligned text that may vary from between three to
I have a UILabel that I need to get the value from as an
I have a UILabel Outlet, and everytime I access its text property with multiple
I have a UILabel called optionsDisplayerBrushSizeLabel who's text property I want to set to
I have a UILabel that I would like to update. It has been added
I have a UILabel with text: 照明タイマーをセットする that is being cut into two lines
I have a UILabel with a dynamic string as the text property. If I
I have a UILabel that is modified while using my app. I want the
I have a UILabel that has a formatted String (formatted for currency), so there
I have a UILabel with space for two lines of text. Sometimes, when the

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.