Skip navigation.
 
mlRe: NSCell Text Alignment
FROM : Keith Renz
DATE : Thu Oct 14 17:03:31 2004

Daniel,

To get similar behavior (truncate end), my table view data source
returns an attributed string whose paragraph line break mode is set to
NSLineBreakByTruncatingTail (you'll want to use
NSLineBreakByTruncatingMiddle).

- (NSAttributedString *)myDescription
{
   // String
   NSString *string = [NSString stringWithFormat:@"%i %@", num, [self
stringFromRamp:ramp]];
   
   // Attributes
   NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc]
init];
   [paragraph setLineBreakMode:NSLineBreakByTruncatingTail];
   NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
paragraph, NSParagraphStyleAttributeName, nil];
   [paragraph release]; // Clean-up.
   
   // Return an autoreleased attributed string.
   return [[[NSAttributedString alloc] initWithString:string
attributes:attributes] autorelease];
}

This may be 10.3 and greater only -- can't remember.

Keith

Related mailsAuthorDate
mlNSCell Text Alignment Daniel Todd Currie Oct 14, 04:29
mlRe: NSCell Text Alignment Daniel Todd Currie Oct 14, 04:48
mlRe: NSCell Text Alignment Daniel Todd Currie Oct 14, 06:03
mlRe: NSCell Text Alignment Keith Renz Oct 14, 17:03