• 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: draw string with ellipsis
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: draw string with ellipsis


  • Subject: Re: draw string with ellipsis
  • From: chaitanya pandit <email@hidden>
  • Date: Mon, 28 Jul 2008 11:07:59 -0400

What u can do is get the actual size occupied by the string using sizeWithAttributes:attrs and center it accordingly.

-Chaitanya

On 28-Jul-08, at 2:23 AM, Vitaly Ovchinnikov wrote:

Thanks, exactly what I need.
Btw, is there any easy way to center this line vertically? Or I need
to measure it's height and offset it vertically myself?

On Mon, Jul 28, 2008 at 9:57 AM, chaitanya pandit
<email@hidden> wrote:
Hi,
Heres what u can do,

NSString *stringToDraw; // the string to draw
NSMutableDictionary *attrs = [NSMutableDictionary dictionaryWithCapacity:2];
NSMutableParagraphStyle *ps = [[[NSMutableParagraphStyle alloc] init]
autorelease];
[ps setLineBreakMode:NSLineBreakByTruncatingTail];
[attrs setObject:ps forKey:NSParagraphStyleAttributeName];
[stringToDraw drawInRect:rect withAttributes:attrs];


-Chaitanya

On 28-Jul-08, at 1:47 AM, Vitaly Ovchinnikov wrote:

Hello,

What should I pass to -drawInRect's attributes to draw NSString as a
single line with ellipsis at the end if it doesn't fit to the rect?
Or point me to another method that can do that.

Thank you.
_______________________________________________

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

_______________________________________________

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


_______________________________________________

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: 
 >draw string with ellipsis (From: "Vitaly Ovchinnikov" <email@hidden>)
 >Re: draw string with ellipsis (From: chaitanya pandit <email@hidden>)
 >Re: draw string with ellipsis (From: "Vitaly Ovchinnikov" <email@hidden>)

  • Prev by Date: Re: NSTextView + other NSView in NSScrollView?
  • Next by Date: sorting two arrays
  • Previous by thread: Re: draw string with ellipsis
  • Next by thread: Re: draw string with ellipsis
  • Index(es):
    • Date
    • Thread