• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I compute the screen width of a particular font?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I compute the screen width of a particular font?


  • Subject: Re: How do I compute the screen width of a particular font?
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Wed, 5 Aug 2009 17:28:28 -0400

Interesting.I finally tried:  [NSString sizeWithFont:<>] as follows.

CGSize strSize = [item.title sizeWithFont:[UIFont
systemFontOfSize:TEXT_FONT_SIZE]];

CGRect centralTitleRect = CGRectMake(TITLE_OFFSET, (rowHeight -
TITLE_LINE_HEIGHT)/ 3.0, strSize.width, TITLE_LINE_HEIGHT);

UILabel *titleLabel = [[UILabel alloc] initWithFrame:centralTitleRect];



I'll try your method to see if I get the same effect.

Thanks.


Ric.

On Wed, Aug 5, 2009 at 3:54 PM, Randall Meadows <email@hidden> wrote:

> On Aug 5, 2009, at 1:46 PM, Frederick C. Lee wrote:
>
>  Greetings:    I need to adjust a UILabel's width per with of its text.
>> What I did was to get the text's length via [NSString length].   Of
>> course,
>> the displayed UILabel width is too narrow to fully display the actual
>> string.
>> So I believe I need to compute the true width based on the number of
>> font-sized characters.
>>
>> Is there a simple, quick way to do this?
>>
>
> myUILabel.text = @"Some text.";
> [myUILabel sizeToFit];
>
>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How do I compute the screen width of a particular font? (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: [OT] Re: Generating random numbers
  • Next by Date: Re: [iPhone] Webview stringByEvaluatingJavaScriptFromString
  • Previous by thread: Re: How do I compute the screen width of a particular font?
  • Next by thread: How do I change a UITableView's row-cell's color upon user selection?
  • Index(es):
    • Date
    • Thread