截断一个字符串并在Objective-c的末尾添加省略号 [英] Truncate a string and add ellipsis at the end in Objective-c
本文介绍了截断一个字符串并在Objective-c的末尾添加省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何截断Objective-C中的字符串,然后在末尾添加省略号?
How to truncate a string in Objective-C and then add the ellipsis at the end?
推荐答案
NSString *origString = @"A very long string blah blah blah";
const int clipLength = 18;
if([origString length]>clipLength)
{
origString = [NSString stringWithFormat:@"%@...",[origString substringToIndex:clipLength]];
}
这篇关于截断一个字符串并在Objective-c的末尾添加省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文