• 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: Create UILabel to fit into text size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create UILabel to fit into text size


  • Subject: Re: Create UILabel to fit into text size
  • From: Dave DeLong <email@hidden>
  • Date: Mon, 29 Dec 2008 22:23:37 -0700

If you look in the NSString (UIStringDrawing) documentation, you'll see that NSString has a -sizeWithFont: method that returns a CGSize, which will be the bounding box for that string when its drawn with the passed in UIFont. You can then use that size as part of the CGRect for constructing a UILabel.

If you need to control things like wordwrap and whatnot, check out the related methods.

HTH,

Dave

On 29 Dec, 2008, at 9:20 PM, Tharindu Madushanka wrote:

Hi
I am new to iPhone application development and please help me on this.
I need to add the contents in a text field to a UILabel. But I can't guess
how long the string in the text field be. There fore, can I make a UILabel
from the text ( I mean to fit the text to UILabel size). I have searched but
could not find a solution. Please help me on this with some code.
I think if I get a CGRect object with some string it could set as UILabel's
frame. can you suggest some code segment to do this.
Thank you
Tharindu
_______________________________________________

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: 
 >Create UILabel to fit into text size (From: "Tharindu Madushanka" <email@hidden>)

  • Prev by Date: iTunes Scripting Bridge examples?
  • Next by Date: Re: respondsToSelector - #import OR compiler warnings?
  • Previous by thread: Create UILabel to fit into text size
  • Next by thread: Re: Create UILabel to fit into text size
  • Index(es):
    • Date
    • Thread