I need to a have smart multiline cut of my long multiline string of text.
Originally I have the following:
On the screen above I pointed the narrow region which I actually have for showing the text. Finally I want to get the following:
The main idea which I look for is how I can truncate multiline text as a whole (not separating it by strings, truncating each of them and then concatenating back).
In more detail, I have 3 strings separated by \n
and concatenated in one long string.
I want to put this long string in the definite UILabel as attributed string under the following conditions:
- the first string must have 1 line
- the 2nd and the 3rd string must have 2 lines maximally
So I want to truncated not only tail of the whole long string by label frame but tail of each string separated by \n
independently.
I know that I could do it dynamically: split each substring by words and concatenate words until the will need more then maximally allowed lines.
But I believe that there is some elegant way to do this using formatting or CoreText.