I have a UILabel whose size is calculated with sizeWithFont:
method. The line break mode is set to UILineBreakModeWordWrap
(same flag is used when calculating the size with sizeWithFont:
)...
Everything works great, label is properly sized and displays my text as required.
Now I need to know the lines that are used to display the label (or the lines that are generated when sizeWithFont:
is used). I could technically write my own implementation of line breaking based on spaces/caret returns, but then it's not going to be guaranteed the same way as Apple's implementation and hence the resulting lines will not be the ones that are used to calculate the size of text, nevermind the fact of reinventing the wheel.
Ideally, I would pass my string, specify the width and line break mode and receive an array of strings representing the visual lines of text.
Any ideas how to make this happen in the most elegant way?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…