6

NSString *longStr = @"AAAAAAAAAA\nBBBBB\nCCCCCCCCCCCCCCCCCC";

How to make this truncation with UILabel for some label width:

AAA...  
BBB...
CCC...
Valerii Pavlov
  • 1,986
  • 1
  • 19
  • 30

1 Answers1

0

You'll need to use separate labels for each line and use UILineBreakModeTailTruncation.

Hint : Split the text over \n and iterate over the array obtained.

EDIT :

Find the number of characters possible per line in the width of the UILabel and then change your text.

Split over \n -> Iterate over the Strings -> Get SubString of length equal to the max width of the UILabel - some value -> Append trailing dots to that SubString and add the resultant string to tempString -> Create UILabel and assign tempString to it

This would give you the desired result.

Akshat Singhal
  • 1,801
  • 19
  • 20