1

I'm using Core Text to render some text in a small frame. Core Text is good at calculating how much of a string that fits in a frame, but if it's too long and needs too be cut, I want to indicate this by adding three dots. Is it possible? How? I've Googled it, without any luck.

1
  • Was my answer of any use to you?
    – Joshua
    Aug 10, 2011 at 12:22

2 Answers 2

0

Just off the top of my head couldn't you do something like this:

CFRange visibleRange = CTFrameGetVisibleStringRange(frame);
int index = (visibleRange.loc + visibleRange.length) - 3; // -3 to make sure the three dots are visible

NSMutableString *newString = [text mutableCopy];
[newString insertString:@"..." atIndex:index]

// Re-create framesetter and frame with new string. Redraw frame.
0

Create a CTParagraphStyle for the text and set kCTLineBreakByTruncatingTail as the line break mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.