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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:46:28+00:00 2026-06-17T10:46:28+00:00

Let me tell you my requirement first, I have strings stored in one string

  • 0

Let me tell you my requirement first,

I have strings stored in one string variable say str,

NSString *str=@"multiple strings";

Next I would like to specify the width where the above strings will get fit into,say width=350 and fontsize=16; Now how would I get to know how many lines the texts will get occupy with given width=350 and fontsize=15.(I mean number of 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-17T10:46:29+00:00Added an answer on June 17, 2026 at 10:46 am

    You can find the size (and hence the height) required to draw a string by using one of the methods in UIStringDrawing.h. This method will give you the size when drawing into a constrained width of 350px:

    CGSize maximumSize = CGSizeMake(350, CGFLOAT_MAX);
    UIFont *font = [UIFont systemFontOfSize:16];
    CGSize size = [str sizeWithFont:font constrainedToSize:maximumSize lineBreakMode:NSLineBreakByWordWrapping];
    

    In this example, maximumSize uses the maximum possible height (effectively infinity) for a CGFloat, and a width of 350px. This effectively means “give me the size of this text by restricting the width to 350px“.

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

Sidebar

Related Questions

First let me tell you what my situation is I have 3 service Providers
First of all let me tell you that i have read the following questions
Okay first let me tell you the story behind the question. We have a
let's say we have a model called Student and it has a string field
First let me tell you that i have searched at least a day long
First of all let me tell you one thing that I am posting this
I have a bit of a strange question. First let me tell you i
First let me tell you what I want to achieve. I want a layout
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a method in java, which looks up a user in

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.