Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 核心文本-小框架文本过多-如何添加三个点?_Iphone_Objective C_Ios_Core Text - Fatal编程技术网

Iphone 核心文本-小框架文本过多-如何添加三个点?

Iphone 核心文本-小框架文本过多-如何添加三个点?,iphone,objective-c,ios,core-text,Iphone,Objective C,Ios,Core Text,我使用核心文本在一个小框架中渲染一些文本。核心文本很擅长计算一个字符串在一个帧中的大小,但是如果它太长,需要剪切,我想通过添加三个点来表示这一点。可能吗?怎样我已经在谷歌上搜索过了,没有任何运气。就在我的头顶上,你就不能这样做吗: CFRange visibleRange = CTFrameGetVisibleStringRange(frame); int index = (visibleRange.loc + visibleRange.length) - 3; // -3 to make su

我使用核心文本在一个小框架中渲染一些文本。核心文本很擅长计算一个字符串在一个帧中的大小,但是如果它太长,需要剪切,我想通过添加三个点来表示这一点。可能吗?怎样我已经在谷歌上搜索过了,没有任何运气。

就在我的头顶上,你就不能这样做吗:

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.

为文本创建CTParagraphStyle,并将KCTLineBreakByTruncingTail设置为换行模式。

我的答案对您有用吗?