I use a table view to show a list of books, where each cell has a UILabel
that shows the book's name and another UILabel
the shows the book's author(s)
My question is about the author(s) label. A book can have multiple authors, and I want it to behave as follows:
- If book has one author ('John Colman') label should be: "John Colman"
- If book has more than one author ('John Colman', 'Bob Night', 'Michael') label should be: "John Colman +2 authors"
Now the problem is this, I want the label to be truncated before the '+'. So for example, if the first author name is long, lets say 'Benjamin Walter Jackson', I want the label to look like this:
"Benjamin Walter Ja... +2 authors"
The default behaviour of course truncates the label in the end, so it looks like this:
"Benjamin Walter Jackson +2 au..."
If I use the middle truncate, there's no promise that it will truncate the label in the right place (before the '+')
I'm looking for a way to do it and as efficient as possible, without impacting the scroll performance of the table view.