pt2ph8 pt2ph8 - 2 months ago 45
iOS Question

UIButton's Title Label Word Wrap with Tail Truncation

I need to enable word wrapping and tail truncation, at the same time, on a

UIButton
's
titleLabel
. Setting numberOfLines to something more than 0 doesn't work, the text stays on one line.

I've already searched around and haven't found a solution. Any idea?

Answer

I solved it the same day I posted this question by putting a UIButton on top of a UILabel with numberOfLines set to 3. I had left this unaccepted to see if someone had a better idea, but apparently there's no other solution.