Truncate NSTextView?

I tried using defaultParagraphStyle, but I cannot get an NSTextView (programmatically added) to crop the text using an ellipse (...).

I set the frame during initWithFrame (150, 20), and I also set maxSize (150,20). However, the text is simply overflowing. If I set the height where half the line is visible, I can see the upper half of the text, however I would like the text to be truncated with ellipsis.

How can i do this?

+5
source share
3 answers

IB, , ( , , ). , , " " ​​ lineBreakMode. , Xcode (, " " ).

, :

[[someTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail];

:

[[someTextField cell] setLineBreakMode:NSLineBreakByCharWrapping];
[[someTextField cell] setTruncatesLastVisibleLine:YES];
+17

, .

( ), Auto Layout NSTextView NSView, NSTextView NSLayoutPriorityWindowSizeStayPut (, 499). NSTextView .

+12

:

NSTextField , !

.

...

[[someTextField cell] setLineBreakMode:NSLineBreakByTruncatingTail];

... ...

- (void)windowDidLoad

, , ...

Stephan NSTextField Truncates. , , Line Break - Truncate Tail , .

-1

All Articles