So I am trying to implement UILabel with UILineBreakModeTailTruncation.
So, for example if the text is "StackOverflow is the best website for programmers", it gets truncated as "StackOverflow is the best..."
It needs to be "StackOverflow is the best ..." (Space + …)
Is there any easy way to implement this ??
Any easy implementations other than subclassing & overriding drawRect, and/or playing around with the frames, (if it character limit frame size, stop it and append ” …”) ??
Look forward to interesting implementations !
As far as I know, Apple does not provide any API for this. You have to write your own implementation. I would calculate the width of the UILabel with the current font, see if it exceeds the maximum width, if it does, truncate text, otherwise present text normally.