I have a UIButton, I want to set title for it with a long text. e.g: @"set dots at the end of UIButton if title is long"
I used:
[btn setTitle:@"set dots at the end of UIButton if title is long" forState:UIControlStateNormal];
--> btn appear as: "set dots...at the"
Now I want to show "set dots at the..."
How I can do?
Thanks All!
Surprisingly, there is no existing post about this for a button label.
Simply do:
[btn setTitle:@"set dots at the end of UIButton if title is long" forState:UIControlStateNormal];
btn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
Accessing the button's titleLabel
lets you adjust the button's label attributes as needed when a direct UIButton
method doesn't exist.
In storyboard after select button go to attribute inspector and set lineBreak property to Truncate Tail.
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With