Re: Clipping drawn text with an ellipsis
Re: Clipping drawn text with an ellipsis
- Subject: Re: Clipping drawn text with an ellipsis
- From: Ryan Dingman <email@hidden>
- Date: Tue, 11 Jun 2002 22:12:28 -0700
Unfortunately, you'll have to roll your own. Apple has planned for allowing developer's to do this since the define the NSLineBreakByTruncatingTail line break mode. The following code would work except for the fact that Apple hasn't bothered to implement the NSLineBreakByTruncatingTail link break mode.
Hope this helps.
ryan
--------------------
NSParagraphStyle *paragraphStyle;
NSDictionary *attributes;
paragraphStyle = [NSMutableParagraphStyle defaultParagraphStyle];
[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
attributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:paragraphStyle, NSParagraphStyleAttributeName, nil];
[aString drawInRect:aRect withAttributes:attributes];
On Tuesday, June 11, 2002, at 08:54 PM, Pete Yandell wrote:
I'm sure this one must have been covered before, but I can't find it in archives or docs, so...
I'm drawing text using NSString's drawInRect:withAttributes: method. This method wraps the text onto multiple lines if it doesn't fit within the width of the given rectangle. What I want to do is have the text clipped to the edge of the rectangle with an ellipsis (...) appended, a la the OS 9 Finder with filenames. (The OS X Finder, of course, is super clever and puts the ellipsis in the middle, but I don't need that.)
Anyone know if there is a simple way to do this? I'm trying to avoid rolling my own routine to do the job and thereby reinventing the wheel.
Pete Yandell
http://pete.yandell.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.