是否有一种简单的方法来拆分NSAttributedString,以便只获取最后50行左右的行?从NSAttributedString中提取最后50行
NSMutableAttributedString *resultString = [receiveView.attributedText mutableCopy];
[resultString appendAttributedString:[ansiEscapeHelper attributedStringWithANSIEscapedString:message]];
if ([[resultString.string componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] count]>50) {
//resultString = [resultString getLastFiftyLines];
}
你是问关于线条或字符? ([结果字符串长度]> 50) - 关于字符,而不是行 – Tala
我猜这两个工程,但我更喜欢行。 –
字符串中的行根据字体大小+ UI元素宽度+自动换行来标识。如果有50个字符可用,请不要使其过于复杂,并使用子字符串,如我的回答 – Tala