Set dots at end of UIButton if header is long

I have a UIButton, I want to set a title with long text for it. for example: @ "set dots at the end of UIButton if the title is long"

I used:

[btn setTitle:@"set dots at the end of UIButton if title is long" forState:UIControlStateNormal]; 

-> btn appear as: "set points ... to"

Now I want to show "given points in ..."

How can i do this?

Thanks everyone!

+6
source share
2 answers

Surprisingly, there is no existing message for the button label.

Just do:

 [btn setTitle:@"set dots at the end of UIButton if title is long" forState:UIControlStateNormal]; btn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; 

Access to the titleLabel button allows you to configure button label attributes if necessary when the direct UIButton method UIButton not exist.

+11
source

In the storyboard, after clicking the button, go to the attribute inspector and set the LineBreak property to Truncate Tail.

. enter image description here

+5
source

Source: https://habr.com/ru/post/982240/


All Articles